Reputation:
I have built a jar file with the newest JRE. When I try to use it in another computer, I get an error that says that the JRE is older.
Can I build a JAR file that will run on this older version of JRE?
Upvotes: 1
Views: 280
Reputation: 15624
Yes, you can specify the target Java version at javac
s command line:
$ javac -help
Usage: javac <options> <source files>
where possible options include:
...
-source <release> Provide source compatibility with specified release
-target <release> Generate class files for specific VM version
This is also supported by build tools like maven and gradle.
This does not check that you don't access classes or methods from the JRE which are not (yet) available in the old version...
Upvotes: 2