I have a project that was compiled to an ear file using maven. This is what was used to compile the code:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6/source>
<target>1.6</target>
</configuration>
</plugin>
Is there a way I can determine what minor version of Java maven used to compile the code?
UPDATE:
I was able to get the major and minor version using just the ear file generated from the maven build by doing the following:
- Extract the ear file using a zip file tool to get to the contained files
- From the extracted files find one of the jars generated from my source code
- run javap using the following (from the dir where the jar file exists):
javap -classpath ./myjarfile.jar -verbose -c com.myorg.myproj.MyClass
The beginning of the output looks like this:
Classfile jar:file:/C:/TEMP/myjarfile.jar!/com/myorg/myproject/MyClass.class
Last modified May 26, 2017; size 944 bytes
MD5 checksum 37996ea9840df04afb5485fedd861f8e
Compiled from "MyClass.java"
public class com.myorg.myproj.MyClass extends com.myorg.myproj.SomeOtherClass
SourceFile: "SomeOtherClass.java"
minor version: 0
major version: 50
flags: ACC_PUBLIC, ACC_SUPER
So it looks like my class was compiled using Major Version 50 and Minor Version 0.
HOWEVER, The question remains, what specific version of Java was used to compile the code? I'm expecting something like what you would get back if you were to type "java -version" at a cmd prompt (e.g. java version "1.7.0_51").
What does 50.0 map to in terms of a "java -version" version?
There are a number of posts regarding this type of mapping, but they all seem to only map the major version. These include the following:
List of Java class file format major version numbers?
https://blogs.oracle.com/darcy/source%2c-target%2c-class-file-version-decoder-ring
http://www.rgagnon.com/javadetails/java-0544.html
Also, I don't seem to have a Java 1.6 environment installed on the machine where I compiled the code, so I'm not sure what maven used to compile the code to Java 1`.6.