java

Removing an element from an Array (Java)

Is there any fast (and nice looking) way to remove an element from an array in Java? ...

Is it possible to invoke methods of a session bean directly after deployment?

I'm using GlassFish. This is what I want to do. I have different ejb modules which can be deployed independently from each other. But I want to have one central ejb module where all the deployed modules have to register. This is because not all modules have to be deployed. I thought the best way is if each ejb module contains a session ...

Swing: how do I close a dialog when the ESC key is pressed ?

GUI development with Swing. I have a custom dialog for choosing a file to be opened in my application; its class extends javax.swing.JDialog and contains, among other components, a JFileChooser, which can be toggled to be shown or hidden. The JFileChooser component already handles the ESC key by itself: when the file chooser is shown (...

Duplicate maintenance - code and documentation

This may not be the best title - I would appreciate it if someone would come up with a better one after reading my problem. Also, I want to say up front that I am largely self-taught on the Internet, so there may be many tools that I am not aware of! I am maintaining software implementing the Flow-Based Programming concept in both Java...

Hibernate: Generate Statistics

So in my persistence.xml I turned on hibernate.generate_statistics. <property name="hibernate.generate_statistics">true</property> My question is.. how do I access them? Where do the statistics go? ...

Dynamically loading a native library inside Java applet

I am trying to write a Java applet that will read from a user's serial port. For this I am using the Java Comm API in conjuction with the RXTX library. I've successfully managed to read data through a local Java application but I can't seem to do the same from within an applet. The problem is that the RXTX library is a native library and...

Invalid scale size. Cannot be less than zero

I am using spring-2.5.6 to connect from a standalone application to an Oracle 10g database (ojdbc14.jar) using the org.apache.commons.dbcp.BasicDataSource. When I try to retrieve a SqlRowSet using the public SqlRowSet queryForRowSet(String sql, Object[] args) throws DataAccessException method I am getting an 'java.sql.SQLException: Inval...

What is a good IDE for Java programming on a low end laptop?

Hello, i have to work away from my desktop computer from time to time (for instance on trips). It is a low end laptop. I can use Eclipse but it is awfully slow. Is there a better choice? If possible not something like vi oder emacs. Laptop: 512 MB DDR RAM Intel Pentium M 760 2.0 GHz Windows XP SP3 There is no possibility to add more ...

Simple Java Date Calculations

I would like to do simple date calculations in Java. For example, compute the difference in days between to dates (having a 0 time component). Of course you could do a simple substraction of milliseconds, divided by the number of milliseconds per day, which works fine - until daylight saving times enter the scene. I am conscious that dif...

XSLT/Java: ERROR: 'Cannot find external method 'max' (must be public).'

I am copying an example from XSLT Cookbook: 2nd Edition (O'Reilly: Mangano, 2006) where Mangano creates a tree diagram with SVG. As a way to quickly test this code, I am simply transforming the XML using JSTL's <x:transform/> tag, and running it in Jetty 6. The XSLT seems to be getting hung on calling java:java.lang.Math:max, saying: ...

"Cached Item Was Locked" causing Select Statement in Hibernate

I am having trouble with getting some caching to work with hibernate exactly the way I would like. I created some example code to replicate this problem I am having. I have one object that contains instances of itself. For instance, a Part that is made up of more Parts. I really need to minimize the select statements that Hibernat...

httpclient vs httpurlconnection

Wich are the main differences between the two? thanks ...

Redirecting from the doView method in a portlet

I'm using Websphere portal 6.0 and I'm wondering if there's a way in which I can tell the server which page to render from the doView method. I know I can do it from the processAction method but unfortunately the semantics of the problem don't allow it. Thank you for your help ...

Uses for the Java Void Reference Type?

There is a Java Void -- uppercase V-- reference type. The only situation I have ever seen it used is to parameterize Callables final Callable<Void> callable = new Callable<Void>() { public Void call() { foobar(); return null; } }; Are there any other uses for the Java V...

Capture JSP output, save to file

I'm tasked with trying creating a site which will create custom HTML templates. The customizations are based-up customized upon user input. I'm currently using tomcat / JSP for the rest of the front end. What I want to do is create the HTML templates in JSP to output conditional HTML code, but instead of display this HTML output to th...

Is it possible to have Castor marshal/unmarshal an EnumMap?

I'm using Castor to marshal/unmarshal my Java objects, one of which contains an EnumMap. Can Castor marshal/unmarshal EnumMaps? I have a mapping file with some nested HashMaps, but I've never pushed an EnumMap through Castor. If it is possible, how is it done through the mapping file? ...

Resource injection in webapplication JBoss 5

Is it possible to inject resources (like message queues, EJBs) using the @Resource annotation in webapplications running in JBoss 5? The webapp is part of an .ear file. ...

How can I use Java to communicate to device through USB port?

I just recently learn Java and try to communicate to the device through USB port connection. I've have used C# with OpenNETCF which allows me to send file and retrieve file on the device through USB port; how can I achieve this with java? I seearch on stackoverflow thread, http://stackoverflow.com/questions/544507/how-to-communicate...

F2 focus in Eclipse for deprecated members

In Eclipse, the F2/focus or a hover on a member gives you a popup with the javadocs. However, if the member is deprecated, you only get a message like 'The field blahblah is deprecated'. Does anyone know if this is a known bug/feature? If yes, is there a handy shortcut to get a javadoc popup for deprecated members? Typically the alte...

What settings affect the layout of compiled java .class files? How can you tell if two compiled classes are equal?

I have an app that was compiled with the built-in Eclipse "Compile" task. Then I decided to move the build procedure into Ant's javac, and the result ended being smaller files. Later I discovered that adjusting the debuglevel to "vars,lines,source" I could embed the same debug information that Eclipse did, and in a lot of cases files st...