How do we decide which java version is used to compile a version of library in maven?

487 Views Asked by At

My local setup has all java 6 configured. I needed catalina jar file. So I took the latest one -

http://mvnrepository.com/artifact/org.apache.tomcat/tomcat-catalina/8.0.15

but that gave me following errors/warnings

warning: javalangObject.class(javalang:Object.class): major version 51 is newer than 50, the highest major version supported by this compiler.

and build failed.

Only way this was possible is that catalina.jar is compiled with java 7 and my setup is using java6. I confirmed that was the case by using an older version of the library.

http://mvnrepository.com/artifact/org.apache.tomcat/catalina/6.0.35

I would like to know how do we know which library version is compiled with which version of java. Specifically in Maven I don't see any such information.

1

There are 1 best solutions below

3
On

Major version of 51 means it was compiled with Java 7. Major version 52 means, it was compiled with Java 8. Java 6 has major version 50.

You may extract some class files out of the jar downloaded from Maven. Then check the major version of the class as below:

$ javap -verbose someclass.class | grep -i major

Which will indicate the javac version used for compiling.