I never understood this completely. If i code an application using JDK 6+ and I use a eclusive to JDK 6+ class then would a user be able to run it with JRE5? IOW is the JDK version tied to the JRE? If the answer is no then would a proper exception(runtime) for a nimbus LookAndFeel be to advise the user to check their JRE version or try upgrade it?
SCJP 6.0, SCJD (400/400), SCBCD for JEE 5, SCWCD 1.4 I do videos for development at
I am probably the only developer ever to have had an orange sized brain tumor in my brain while learning development!!
Yucca Nel wrote:I never understood this completely. If i code an application using JDK 6+ and I use a eclusive to JDK 6+ class then would a user be able to run it with JRE5? IOW is the JDK version tied to the JRE? If the answer is no then would a proper exception(runtime) for a nimbus LookAndFeel be to advise the user to check their JRE version or try upgrade it?
No he will not be able to run the code, because, yes, they are connected. Generally, the version you use to run a code should be at least equal to the version you compiled with (if you don't use any specific target when compiling). Otherwise you'll get an unsupported class version exception (checked through the major.minor versions of your compiled class(es)...).
If user's environment allows an upgrade, that should be the way. You can have more than one JRE versions install, so you could install the newest version and use it with you app and leave the rest of the user's system as it is...
for instance JDK is JRE + Developer tools bundled together, JRE contains the Java runtime, on the other hand JDK contains Java runtime with some developer tools, like Debugger, a compiler and other stuff, so there versions are definitely tied together
If you compile a class with JDK version N, then you need JRE version N or newer to run it. So, a class file compiled with JDK 6 will normally not run on JRE 5 or older - but a class file compiled with JDK 5 will run on JRE 6.
When you compile your class, you can specify a command line switch to produce a class file that it compatible with a certain JRE version, for example:
javac -target 5 MyProgram.java
This will create a class file that is compatible with JRE 5. However, this does not mean that it will run on JRE 5 - if you have used classes from the standard API that are new in Java 6, it will still not run on JRE 5. The "-target" switch only makes sure that the class file version is compatible with the JRE version that you specify.