Let me be more explicit. It appears that it is not possible to run a jar file containing .class files compiled using the JDK 6 on computers that only have the JRE 5. I tried to run some jar files on some computers that only had the JRE 5 installed, but I kept getting a message saying that the main class was not found (the manifest files are fine). When I tried to run the jar files on computers that had the JDK 6 installed, the programs worked fine.
I don't want every person who will be using this program to have to download the latest JRE. Will I solve this problem if I compile the files using the JDK 5.0?
Hello guys, After researching this subject, I'd like to mention that compiling Java 5-compatible programs, using the JDK 6, using the -source and -target parameters, won't always work, as these parameters won't detect references to classes that were introduced in subsequent Java versions.
I suggest that anyone trying to take care of a similar problem compile his or her programs using the JDK 5 instead. [ March 22, 2007: Message edited by: Clark Johnson ]
Joined: Mar 22, 2005
Originally posted by Clark Johnson: ... as these parameters won't detect references to classes that were introduced in subsequent Java versions.
I'm not sure what you mean by this. All those settings are doing is making sure that the class files produced can be run on an earlier JVM. If the code contains JDK6-only methods, then you need to make sure that they are not executed on a Java 5 JVM (by including appropriate checks in the code).
Obviously, JDK 5 will not be able to compile code that uses any JDK 6 methods, so the workaround of using JDK 5 to compile the program is not really going to work.
Joined: Mar 08, 2007
Obviously, JDK 5 will not be able to compile code that uses any JDK 6 methods, so the workaround of using JDK 5 to compile the program is not really going to work.[/QB]
Correct, but depending on the size of your program, it can easier to have the JDK 5 tell you which methods won't work than rereading the documentation of all the methods you used. It seems like a safer and more efficient way to take of this problem.