Tuesday, February 9, 2016

How to check the JDK version used for compiling a java class

You can use javap command to find the compiled version of a class. javap (Java Class File Disassembler) tool is a tool provided with JDK to disassemble class files.

Unix:

Open a terminal and change the working directory to the place where your class is located.
javap -verbose HelloWorld.class| grep "major"
 

Windows:

Open a command prompt and change the working directory to the place where your class is located.
javap -verbose HelloWorld.class | findstr "major" 
 
E.g.: 
 
 
 
 Following is the mapping between the major version and the relevant JDK version.
Major VersionComipled JDK version
461.2
471.3
481.4
495
506
517
528
 
 

No comments: