java

Winapp (c#) calling java app -> set progressbar

Hello, I've got a C# winapp that communicates with a java app to retrieve data over tcp. Now I want to add a progressbar for the waiting and showing that the download of the data is busy. Because at this moment the winapp freezes until it has all the data from the java. Now I was wondering how I could program it. Because I assume that ...

Introducing Brevity Into C# / Java

Background Currently, if I want to create a new object in C# or Java, I type something similar to the following: List<int> listOfInts = new List<int>(); //C# ArrayList<String> data = new ArrayList<String>(); //Java C# 3.0 sought to improve conciseness by implementing the following compiler trick: var listofInts = new List<i...

Can you run glassfish with JRockit?

Has anyone tried running glassfish with JRockit? I see some references saying it's not possible but they are very outdated. Anyone tried this? ...

Suggestions/sample code for fileSystemWatcher in Java

I am trying to build a fileSystemWatcher in java (similar to FileSystemWatcher in C#). Please suggest whether java has any built in framework capability for this or suggest/direct to any sample/open source projects. ...

Hibernate Query API and Java 1.5/Generics

All APIs in Hibernate are from 1.4 and are thus not using java generics. So I wonder how "safe" the following is: (preconditions: name column is of datatype String, or atleast compatible to String) @SuppressWarnings("unchecked") public List<String> getAll() { Query q = session.createQuery( "select name from Customers"); ...

Constructor Parameters - Rule of Thumb

In general, what is the maximum number of parameters a class constructor should accept? I'm developing a class that requires a lot of initialization data (currently 10 parameters). However, a constructor with 10 parameters doesn't feel right. That leads me to believe I should create a getter/setter for each piece of data. Unfortunately, ...

Best way to convert from "Simple Class Name" to "Full Class Name" to Object in Java

So lets say I have an object that it stored in a Database: com.test.dummy.Cat The cat has an integer id. Outside of my "world" the reference to the object is a String of the form: Cat-433 Where 433 is the Cats assigned Database ID. When I get the String passed to me, I need to be able to find it in the Database. So I do this: St...

Do you use (or define) non standard annotations, and for what reason. How about recursive annotations?

The question tells it all. For the experts, is there a reason the SUN java 5 compiler accepts recursive annotations (contrary to the langspec), while the later compilers do not? I mean, what could be an argument against recursive annotations. Edit: a recursive annotation is something like: @Panel(layout=BorderLayout.class, nested=...

What is the easiest way to wrap a Stored Procedure in a Web Service?

We have a Legacy system that contains a number of stored procedures that we'd like to expose to other applications as web services. We are building the web services with JBoss. The stored procedures can run from Oracle, DB2 or MS SQL Server databases. JDeveloper has a wizard to generate the stubs and deploy to an ear file that would ru...

Does Java have a complete enum for HTTP response codes?

I'm wondering if there is an enum type in some standard Java class library that defines symbolic constants for all of the valid HTTP response codes. It should support conversion to/from the corresponding integer values. I'm debugging some Java code that uses javax.ws.rs.core.Response.Status. It works, but it only defines about half of t...

What is the memory overhead of a Java method?

What is the memory overhead of a function in a class? For example, Class A { int a } Class B { int a int foo(int); } So 100 instances of class A should be 80 bytes. What about 100 instances of class B? ...

Problems reading/writing UTF-8 data in MySQL from Java using JDBC connector 5.1

Hello, I have an scenario with two MySQL databases (in UTF-8), a Java code (a Timer Service) that synchronize both databases (reading form first of them and writing/updating to second) and a Web application that lets modify data loaded in the second database. All database access are made using IBATIS (but I detect that I have the sam...

What are some interesting uses for Java Agents?

Starting with Java 5 there's an option to add Java Agents to the class loader. Have you written any Agents? have you used any Agents? What are interesting uses of Agents? ...

RMI interface design principles

Im currently working on an RMI client that will talk to an RMI server (developed by a different division of the company I work for). The other team own the interface, but IMO it's overly complex, with many different types being passed backwards and forwards, as well as an unnecessarily (IMO) complex exception hierarchy. I've expressed ...

Really force file sync/flush in Java

How can data written to a file really be flushed/synced with the block device by Java. I tried this code with NIO: FileOutputStream s = new FileOutputStream(filename) Channel c = s.getChannel() while(xyz) c.write(buffer) c.force(true) s.getFD().sync() c.close() I supposed that c.force(true) togehter with s.getFD().sync() should b...

Way of jumping to a page in a local pdf?

My question is similar to "How can I programmaticly open a pdf at a certain point?", but the PDF is local, not on a web server. I need a way to jump to a given page in a PDF that is on the users computer, that works across versions of Acrobat (or using an alternative PDF viewer like Foxit Reader). The PDF is going to be called from a Ja...

Serialize Object in GWT

What's the simplest way to serialize a bean to a string using GWT? I prefer not to use GWT.create() invocations. ...

Swing UIManager.getColor() keys

is there a list somewhere of the UIManager.getColor() keys for Swing? I can't seem to find it online, just occasional references to strings like "Panel.background" and "Table.selectionBackground". ...

Which is the fastest way to access native code from Java?

Which is the fastest way of calling a native library from Java? The ones I know about are NativeCall - what we're currently using JNA - haven't used it, but looks reasonable JNI - looks horrendous to write, but we'll do it if we get the speed ...

Best (most efficient) DataType to use for UUIDs as JPA IDs

I want to use UUIDs as IDs for my JPA Objects. I am currently just using a String to store the UUID. What would be more efficient? ...