pebbles
pebbles

Reputation: 366

Installing JDK 1.2 in Windows 7

I want to recompile an old jar file (which was compiled in java 1.2). So that there are no errors i need to compile it in Java 1.2 aswell. But havent found a jdk 1.2 which i can install on windows 7 (and 64bit).

Any suggestions?

thanks in advance!

Upvotes: 1

Views: 1071

Answers (2)

Durandal
Durandal

Reputation: 20069

There are two scenarios, just compiling old code and actually developing for an old JRE.

For just compiling you don't need an old JDK, you can adjust the target language level javac compiles with the -target option (see: https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javac.html) - Although there may be edge cases that may break the compiled code if the compiler decides to select a different overload for a method that does not exist in the old JRE.

For developing old JRE compatible code, you could use above method but you run the risk accidentially using an API that isn't present in the real old JRE. To avoid that problem you need the actual 1.2 API, meaning you need the rt.jar file from a real 1.2 JRE/JDK. This can be added into your project in your IDE (and the current e.g. 1.8 JDK removed). The detailed procedure how to set this up depends on the IDE. Likewise the 1.2 rt.jar can be provided to javac, also using command line switches. Again you need no runnable 1.2 JRE to compile/develop.

Upvotes: 2

Piyush Mittal
Piyush Mittal

Reputation: 1890

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

From Oracle article : http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/javac.html

Cross-Compilation Example

Here we use javac to compile code that will run on a 1.4 VM. % javac -target 1.2 -bootclasspath jdk1.2/lib/classes.zip \ -extdirs "" OldCode.java

Upvotes: 3

Related Questions