I’m modifying a java program which was written in 2004 using javaw.exe from J2re1.4.2_03.
problem:
Is there a way to figure out which JDK compiler a programmer used to compile a java file with?
backstory:
I recompiled the java file with jdk5’s javac.
I run it with the javaw.exe from the j2re1.4.2_03, it gives me a popup error “Could not find the main class. Program will exit.”
From some googling, error message means classes compiled with an even older javac.exe
If I run it with a jdk5’s javaw.exe, no error.
I want to avoid recompiling all the class files as I do not have all of the original java files to do a complete recompilation.
Is there a way around this or a way to figure out which compiler the original programmer used to do this? or one which works better with
thanks in advance
I’m not so clear what your exact question is.
If you’re wondering how the find out what version of Java a classfile is from, the header of a class file can be read. You can see the info here, and there are tools around that will inspect the files for you.
You should generally avoid using class files compiled by different compilers together. There are some ways around it, but you’ll be in classpath hell. Are the new Java file compatible with the older versions (e.g., no generics?). You can always get the older compilers from Sun and just compile your newer files with this compiler.