Adverts
This is a little problem I can across while trying to Javadoc a project I'm working on. While I realized that this sort of problem existed I've always been careful to avoid it. The error reported by the Javadoc tool was:
Constructing Javadoc information... /some/path/UniqueFilenameValidator.java:18: cannot access com.crazysquirrel.util.jsf.Messages bad class file: /some/path/web/WEB-INF/lib/utilities.jar(com/crazysquirrel/util/jsf/Messages.class) class file has wrong version 50.0, should be 49.0 Please remove or make sure it appears in the correct subdirectory of the classpath. import com.crazysquirrel.util.jsf.Messages;
The problem is that I have compiled the source with Java 6 but the Javadoc tool is running as Java 5. It is also possible to elict an error message such as "Unsupported major.minor version 50.0" when trying to run a class compiled on a Java 6 VM under anything other than a Java 6 or later VM.
The problem stems from the fact that JVMs are backwards but not forwards compatible. For example a Java 5 VM can run a class compiled under Java 1.4 or even 1.1 (and I think 1.0). That same Java 5 VM can not, however, run a class compiled to Java 6 specifications. I make a point of saying Java 6 specifications because one can supply the -target flag to the compiler which will cause the compiler to produce class files that are of a particular version (within reason - I think the earliest you can now compile as is 1.4).
Each new release of the JVM increments the version number of the class file. The list below shows the class version numbers that I know about:
- Java 6: Version 50.0
- Java 5 (1.5): Version 49.0
- Java 1.4.2: Version 48.0