Backtrack:  
 
by lunarg on May 28th 2015, at 12:10

You can compile for older versions of the JRE by setting the compiler target compliance level. This allows you to generate class files that are usable on older versions of the JRE as well as the current one.

From your IDE, you will be able to select the compliance level, but if you're compiling manually using javac, this can be done by setting the appropiate command line parameters: -source and -target.

For example, to compile for JRE 1.6, do this:

javac -source 1.6 -target 1.6 MyClass.java

A quick explanation:

  • -source sets the source compatibility to the specified version, and ensures that your code is usable on the specified JRE.
  • -target specifies the compliance level of the generated machine code. Specifying this level will allow you to run the compiled class on that version of the JRE, or newer.

You should always try to specify both source and target compliance levels. They are usually set the same.

 
 
« February 2025»
SunMonTueWedThuFriSat
      1
2345678
9101112131415
16171819202122
232425262728
 
Links
 
Quote
« I needed a password with eight characters so I picked Snow White and the Seven Dwarves. »