[PJUG Javamail] javac -version in MANIFEST.MF ?
Derek Chiles
pjug.org at derekchiles.net
Mon Jun 15 19:56:20 EDT 2009
Hi "Send Here",
On Jun 15, 2009, at 12:58 PDT, Send Here wrote:
> Is there a standard manifest header or standard practice for
> publishing the "javac -version" used in compiling the .class files
> inside a JAR? "Specification-Version" seems like an ideal header to
> show the version of your application, but then you'd need a second
> header to record the version of javac used to compile.
To be precise, the version of the java *compiler* used should not
matter at runtime. What matters is that the compiler emitted valid
Java bytecode in the valid Java .class file format. The Java VM spec
handles .class format versioning; for example version 48 for Java
1.4 .class files, version 49 for Java 5, and version 50 for Java 6.
I think you want to be interested in the .class file version instead
of the output of javac -version.
> I'm working in several environments right now with multiple javac
> versions and it's my understanding that you cannot successfully run
> one jvm on a combination of class files built with different major
> versions of the compiler.
I'm not a JVM expert but I don't believe this should ever be a
problem. JVMs are backwards compatible by design and spec; they can
load older versions of the .class file format. If they weren't
backwards compatible, you'd often run into problems where your third-
party library would not work because it was compiled on an older JDK.
You'd have to upgrade all of your application's jar files before you
could upgrade your JRE, which would be a pain to say the least.
What you can't do is run newer class file versions on an older JRE.
For example, trying to load version 50 .class files in a Java 5 JVM
will fail at class load time.
If you are in a mixed JRE environment, the safest bet would be to
compile everything down to the lowest common denominator by always
specifying the "javac -target" option -- e.g. "javac -target 1.4" or
"javac -target 1.5" (for java 5.0).
That, or push for an upgrade to Java 6, since Java 1.4 is officially
EOL and Java 5.0 will be officially EOL'd on October 30.
HTH
cheers,
Derek
More information about the Javamail
mailing list