Primm Primm - 1 year ago 106
Java Question

How do i compile a .java with support for older versions of java?

I want to compile my .java's (several) into one .jar that are compatible with at least 1.6 and newer, preferrably 1.5 and newer versions of java. (I have 1.7.0_5)

Answer Source

Yes, you can set the version of compiler at compile time. And compile your java code into old versions of java.

From Oracle article :

Cross-Compilation Example

Here we use javac to compile code that will run on a 1.4 VM.

% javac -target 1.4 -bootclasspath jdk1.4.2/lib/ \
             -extdirs ""

You might also need following parameter to set denote the version of your code.

-source release

-Specifies the version of source code accepted. The following values for release are allowed:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download