Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to run a .jar 1.7 program with an older version java 1.6?

Tags:

java

eclipse

jar

I have a code.jar running well in 1.7 version java, but when using another computer with linux with version 1.6 it is giving me an error, how can I run it in 1.6 version?

like image 849
user1475288 Avatar asked Dec 14 '25 04:12

user1475288


2 Answers

Use the cross-compilation options when invoking javac.

If only the -target option is specified as recommended in most other replies, the 1.7 SDK will issue a warning about -bootclasspath. That option requires an rt.jar of the target JRE version (note not JDK). It allows the compiler to check that the classes, methods and attributes of the code that reference core Java SE are actually present in the rt.jar. This is very important to ensure compatibility.

like image 124
Andrew Thompson Avatar answered Dec 15 '25 16:12

Andrew Thompson


If the code is not compiled with an older Java compatibility flag, you won't be able to run it on 1.6.

like image 24
Dan D. Avatar answered Dec 15 '25 16:12

Dan D.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!