java

Has anyone found Garbage Collection tuning to be useful?

I've read plenty of articles about tuning GC in Java and have often wondered how many people really use some of the more advanced features. I've always avoided tuning where possible and concentrated on writing the simplest possible code I can (Brian Goetz's advice) - this seems to have worked well for me so far. Are these tuning strate...

Having a lot of trouble deploying a java applet

I'm new to Java. I'm simply trying to build a .jar file of my applet so I can run it from my browser. This is what my directory structure looks like: C:\java\pacman\src contains all of the .java class files. C:\java\pacman\assets contains about 4-5 images and audio files. If I try to use the following code: Image someFile=getCod...

To use nested genericized collections or custom intermediate classes?

Before the introduction to generics to the Java language I would have written classes encapsulating collections-of-collections-of-collections. For example: class Account { private Map tradesByRegion; //KEY=Region, VALUE=TradeCollection } class TradeCollection { private Map tradesByInstrument; //KEY=Instrument, Value=Trade } Of ...

Do you know of a Java library to access the native linux api?

Do you know of a Java library to access the native linux api? I guess something like this must use JNI. So be it. ...

Simulating "faster time" in linux

I have a Java app that runs on linux that has a lots of events and business logic that revolve around times and dates. For testing, is it possible to tweak something into time going faster. Let's say, make a whole computer-year finish in one hour wall time? ...

How to use sound and images in a Java applet?

Question 1: How should I structure my project so the sound and images files can be loaded most easily? Right now, I have the folder: C:\java\pacman with the sub-directory C:\java\pacman\src containing all the code, and C:\java\pacman\assets containing the images and .wav files. Is this the best structure or should I put the asse...

Reading a UTF-8 String from a ByteBuffer where the length is an unsigned int

I am trying to read a UTF8 string via a java.nio.ByteBuffer. The size is an unsinged int, which, of course, Java doesn't have. I have read the value into a long so that I have the value. The next issue I have is that I cannot create an array of bytes with the long, and casting he long back to an int will cause it to be signed. I also...

Adding Image to a database in Java

I am trying to add an image to a BLOB field in a mysql database. The image is going to be less then 100kb in size. However I am running into problems and was wondering what would be a better way to add this data to the database? com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'Data' at row 1 PreparedStatem...

How Do I Document Packages in Java?

In the Java APIs I can see Javadoc comments for packages. How/where do I place Javadoc comments to document a package? ...

Extending ByteBuffer class

Is there any way to create class that extends ByteBuffer class? Some abstract methods from ByteBuffer are package private, and if I create package java.nio, security exception is thrown. I would want to do that for performance reasons - getInt for example has about 10 method invocations, as well as quite a few if's. Even if all checks ...

Would you use AOP for database transaction management?

A while back I wrote an application which used Spring AOP for defining which methods were transactional. I am now having second thoughts as to how much of a great idea this was; I have been hit a few times after a minor refactor (changing method signatures etc), which of course doesn't become apparent until something actually goes wrong ...

Need Help with Java JMS ResourceAllocationException

I am getting the following error: javax.jms.ResourceAllocationException: [C4073]: A JMS destination limit was reached. Too many Subscribers/Receivers for Queue The setup was done in such a way that there is one provider and two consumers. Is the reason this error is happening because it is a queue and it can only have one provide...

What is the best Java email validation method?

What are the good email validation libraries for Java? Are there any alternatives to commons validator? ...

Case-insensitive equals using Hibernate Criteria

I've seen Restrictions.ilike('property', '%value%'), but would like to generate SQL like: lower(property) = 'value'. Any ideas? I used: Restrictions.eq("email", email).ignoreCase() since Expression is deprecated. The SimpleExpression will call toLowerCase() on the value, so it is not necessary to do it beforehand. See: SimpleE...

JSP.13.8 Example Simple Tag Handler Scenario doesn't work?

This test was prompted by reading a question on the Sun java forums and thought I would try it out. The JSP2.0 specification section JSP.13.8 contains an "Example Simple Tag Handler Scenario". I copy and pasted the code fragments and attempted to run it. Environment: Apache Tomcat version 5.5.26 and 6.0.14 (tested on both) Java: 1.5 ...

How do I get the length of an MP3 from its URL?

If I know the URL of an MP3 file, what is the easiest/fastest way to get its length, bitrate, size, etc? How can I download just the ID3 tag part of the MP3 to get these details? ...

Running Java on a Web Server

I have written a standalone Java application that I've packaged into a jar file that takes in some command line arguments, does some hardcore computations, and then writes out the result to a file along with some output to the default output stream pointing to where the file with the results are. I now want to create a website around th...

How to add external pages to Java code documentation?

When programming in C++, I use Doxygen and frequently create external .dox files for additional documentation that won't fit well in a specific class or method - for instance, file format documentation (for files that are accessed by multiple classes). I tried to find a way to do the same in Java, but it appears that javadoc doesn't have...

How to get the z order of JInternalFrames in a JDesktopPane

How would one go about getting the z order (layer depth of ) all the JInternalFrames inside a JDesktopPane. There does not seem to be a straight forward way for this. Any ideas? ...

What are the (gotchas and) limitations when using POI to create Excel workbooks?

Just saw a crash as we exceeded 255 columns. Maybe this question should go directly to POI, but lets say I do not want to disturb them in their effort to further develop the increadibly useful API it already is. ;-) The limitations page is not increadibly detailed. So: What are your experience of actual limitations assuming the output s...