Compiling with JDK 1.5

Posted by admin
on October 11, 2006 @ 03:42 AM
Prior to JDK 1.5, javac ignored classpath manifest.mf entries in jar files, for example:

- someclass.java references classes in child.jar
- parent.jar includes child.jar in its classpath manifest

Running:
javac -classpath parent.jar someclass.java

you receive "class not found" errors for the classes included in child.jar.

I can see how in some cases this was inconvenient as it meant that if a product (such as Orbix) splits its functionality over a lot of .jar files, then you have to list most/all of these .jar files in your CLASSPATH when compiling the project.

The Java 1.5 compiler is now aware of Manifest.mf files within jar files. This introduces some unexpected side effects as the javac 1.5 looks to recursively walk/unwind the jar stack. Depending on the number of jars in the manifest, this can increase compile times considerably. If you run into this problem the quickest solution looks to be to remove the jar containing the manifest from your CLASSPATH. Other JDK tools such as javap, javadoc, etc.. still ignore the Manifest.mf file.

Thanks to Ciaran McHale for the heads up on this one.

Comments

Leave a response