Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How can you compile a java program in all the previous versions of java using a single version?

user-image
Question added by himanshu mittal
Date Posted: 2013/06/26
Deleted user
by Deleted user

it depends on the JVM version, for example: a1.4 JVM won't run a .java file compiled by a1.6 compiler unless you use compilation flags as follows: in you console you can try this % javac -target1.4 -bootclasspath jdk1.4.2/lib/classes.zip \ -extdirs "" OldCode.java -target : tells the used compiler to generate code that will run on an older JVM.
-bootclasspath : compile your code against the APIs of the older version of Java.
for more information of using 'javac' command, see it's documentation on http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/javac.html

Amitesh Rai
by Amitesh Rai , SOFTWARE DEVELOPER , techzone technology pvt ltd

javac -source jdk_version programName.java

More Questions Like This