java

How to check if a double has at most n decimal places?

Currently i have this method: static boolean checkDecimalPlaces(double d, int decimalPlaces){ if (d==0) return true; double multiplier = Math.pow(10, decimalPlaces); double check = d * multiplier; check = Math.round(check); check = check/multiplier; return (d==check); } But this method fails for chec...

Best GUI framework for Java

I want to start a new project with Java; In the past I used to start with Struts + Tiles; but tiles was very complicated; I don't know the latest version of Tiles; I need your recommendations in details for a good GUI framework; Thanks. Duplicate of this question. ...

Connection pooling in hsqldb

What is the best way to implement connection pooling in hsqldb, without compromising on the speed? ...

Excel currency format with Apache POI

I use Apache POI to write excel sheets. I'm very happy with it, but I have the following problem: my program is multi-currency and internationalized. In the excel sheet I write, I want my currency cells to be properly formatted. For that, I need a routine that would build the right Excel currency format (eg: "[$$-409]#,##0.00;-[$$-409]...

Have you tried Spring Workflow already ?

Spring Workflow has now been published. Have you tried it yet? For what kind of scenario? What is your impression? How do you find it stacks up against other workflow libs? Found any good docs or tutorials? ...

Can you help me gather a Java Best Practices online material collection?

I work on a medium sized development team that maintains a 8+ years old web application written in Java 1.4. For new development I always try to convince people to adhere to newer standards and best practices, That goes from simple things like using new naming standards like HtmlImplementation over HTMLImplementation, to things like why...

Java Video Player

I need a java api, that cannot use JMF, to play video interpreted by the SO codecs but i want to retrieve the each frames in java code. Somebody know some? ...

How does JSF generate the name of the form input field?

Any idea anyone? Is it possible that we specify the name of the form input field? How to go about doing that? ...

Issues with Image loading in J2ME applications on Motorola phones

The standard way to load an image in a J2ME application is using the Image.createImage method and the recommended image format is PNG. Now, the J2ME specs dont lay down any restrictions on the implementation of this method or the in memory representation of an Image so, each vendor has a different implementation. Motorola in particula...

100% Code Coverage with logging code?

After writing new methods and unit tests for them I usually check the code coverage using the Agitar Eclipse plugin. But additionally to business logic there's a lot of logging code like: if(log.isDebugEnabled()) { log.debug("Angela Merkel is REALLY hot!"); } When Agitar checks this code, it (of course) complains about the fact, that...

Support for EJB2 with Jboss 5CR2

How I can configure Jboss 5 to support EJB2? I'm testing the new release of jboss (5) and need to deploy my old EJB2 ...

Swing transparency using JNI

I'm trying to create a simple Java application that displays a frame containing a JButton. I'm using JNI to add transparency to the window. The window is transparent but the button is not. Also, when I move the window the button doesn't move with the window. The same thing happens with a JLabel. If I use a Button instead of a JButton it ...

How to rename java.exe/javaw.exe process?

Always when I run java application it will display in Windows Task Manager is java.exe or javaw.exe. How to rename java.exe or javaw.exe process without wrapper by other programming languages. ...

What is the best open-source java charting library? (other than jfreechart)

Why are there not more opensource easy to use charting libraries for Java?. The only successful opensource project in this area seems to be jfreechart, and it doesn't even have any documentation or examples available. ...

How to set a timeout during remote ejb lookup?

I'm trying to access a remote ejb which is not available yet. But the lookup takes 5 min before I get the NameNotFoundException. Is there a way I can set the lookup timeout to a lesser value so that the client application doesn't hang for 5 mins? Thanks in advance... ...

How do I unit test jdbc code in java?

I'd like to write some unit tests for some code that connects to a database, runs one or more queries, and then processes the results. (Without actually using a database) Another developer here wrote our own DataSource, Connection, Statement, PreparedStatement, and ResultSet implementation that will return the corresponding objects base...

How do I update a pre-existing Jar file

I've got a WAR file that I need to add two files to. Currently, I'm doing this: File war = new File(DIRECTORY, "server.war"); JarOutputStream zos = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(war))); //Add file 1 File file = new File(DIRECTORY, "file1.jar"); InputStream is = new BufferedInputStream(new FileInputSt...

In java, how do you write a java.awt.image.BufferedImage to an 8-bit png file?

I am trying to write out a png file from a java.awt.image.BufferedImage. Everything works fine but the resulting png is a 32-bit file. Is there a way to make the png file be 8-bit? The image is grayscale, but I do need transparency as this is an overlay image. I am using java 6, and I would prefer to return an OutputStream so that I ...

modern for loop for primitive array

Hi, Is there any performance difference between the for loops for primitive array? Assume double[] doubleArray = new double[300000]; for (double var: doubleArray) someComplexCalculation(var); or for ( int i = 0, y = doubleArray.length; i < y; i++) someComplexCalculation(doubleArray[i]); Test result I actually went and...

unmarshalling an axis generated (multiref containing) soap response with jaxb

hi! I'm consuming an axis 1.4 web service that returns soap responses that I want to unmarshal into my domain objects using jaxb annotations. My initial tests worked very well until some of the returned messages had multiRef elements. Objects that were marshalled using multiRef were showing up as null in my client side annotated model ...