Compiling java code and creating jar online

Piyush picture Piyush · Jul 16, 2012 · Viewed 8.4k times · Source

My problem: I have JDK 1.7 version on my machine. The jar I created with this does not run on my Unix machine as it has JRE 1.4 installed (I don't have admin rights to this machine).

So, is there a way to compile my code with version 1.4 w/o uninstalling 1.7 on my machine. Can it be done online?

Answer

kosa picture kosa · Jul 16, 2012

You may use -target version option to perform cross-compilation.

Example as per javadoc

% javac -target 1.4 -bootclasspath jdk1.4.2/lib/classes.zip \              -extdirs "" OldCode.java