rhombidodecahedron
rhombidodecahedron

Reputation: 7922

Dependencies of a JAR

I created a Jar with Java 6. Now I'm creating a release document and recording 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 into a Jar?

Upvotes: 4

Views: 180

Answers (2)

Konrad Reiche
Konrad Reiche

Reputation: 29493

I only know a manuel solution: try it out. There are, however, two things to consider.

  1. For which version is the code language compatible?
  2. For which JRE will it execute?

The first you can do with your current JDK, just iterate over the -source and -target arguments which you pass to your javac compiler. This will, however, not prevent you from using classes and methods from the JDK you are using. If you do, the code will not execute for a lower JRE, if you are using classes or methods that where not present back then.

The savest way would be to install all different JDKs along and try to compile the code with each of their compilers.

Upvotes: 1

Wug
Wug

Reputation: 13196

If you created the jar with java 6 and did not specify a different version of output bytecode, the generated class files will require Java 6 or greater. You can experiment to see what versions of bytecode you can generate with your source with the -target command line option if you're compiling manually, if you're using eclipse or some other IDE, most have settings that control the generated bytecode version in project options or somewhere similar.

A related post about determining the bytecode versions of class files: What version of javac built my jar?

Upvotes: 0

Related Questions