JAR dependencies

I created a Jar with Java 6. Now I create a release document and write the dependencies. How can I find the earliest version of Java that can successfully run the Jar, and the earliest version of Java that can successfully compile the source in the Jar?

+4
source share
2 answers

I only know the manuel solution: try it. However, there are two things to consider.

  • For which version is the code language compatible?
  • Why will the JRE be run?

The first thing you can do with your current JDK is to simply -source over the -source and -source arguments that you pass to your javac compiler. This, however, will not stop you from using the classes and methods from the JDK that you are using. If you do this, the code will not execute for a lower JRE if you use classes or methods that are not present there.

The easiest way would be to install all the different JDKs and try to compile the code with each of your compilers.

+1
source

If you created a jar of java 6 and did not specify a different version of the output bytecode, the generated class files will require Java 6 or more. You can experiment to find out which versions of bytecode you can generate using the source with the -target command-line option, if you compile manually, if you use eclipse or some other IDE, most of them have settings that control the generated the bytecode version in the project options or something similar.

Related article on versioning bytecode files: What version of javac built my jar?

0
source

All Articles