Skip to content
Advertisement

find the compiled class version number

My project consists of some third party jar files, which was compiled in different version of java. My project is using older version of java so i am getting UnsupportedClassVersionError while executing the application. Is there any other way to get the version of java/jre number[45..51] in which the class files are compiled so that i can check the jar files before using it.

Advertisement

Answer

You can use javap (with -v for verbose mode), and specify any class from the jar file. For example, looking at a Joda Time jar file:

JavaScript

Here the -cp argument specifies the jar file to be in the classpath, the -v specifies that we want more verbose information, and then there’s the name of one class in the jar file.

The output starts with:

JavaScript

The “minor version” and “major version” bits are the ones you’re interested in.

It’s possible that a single jar file contains classes compiled with different versions, of course.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement