- TL;DR – Learn how to find Java version from any compiled class files with our easy guide. Perfect for developers needing quick insights. You can determine Java Version of Compiled Class Files Easily
You can check the Java version from which class files were compiled using the javap
tool, which is included with the Java Development Kit (JDK). javap
is a command-line utility that disassembles class files and provides information about the bytecode, including the version number.
- Make sure any JDK version is installed in your machine first, then Open a command prompt or terminal window.
- Navigate to the directory where the class file is located using the
cd
command (change directory). - Run the following command:
javap -verbose
4. Replace with the name of the class file (without the .class
extension).
For example, I have HelloWorld.class file in my bin or target folder, I would hit following command in the terminal to know the java version of this file.
javap -verbose HelloWorld
Game of major version in java
For my current class "EmpDashboardController.java" file I complied it through my X version of java, Now I have to figure out what jdk version was used to complied this file!
I will hit the command "javap -verbose EmpDashboardController" directly.
Look for the "major version" field in the output. This field indicates the Java version from which the class file was compiled. The major version number corresponds to a specific Java version.
In my example, it is showing, major version 55.
Major versions list
Here are some common major version numbers and their corresponding Java versions:
Java Version | Major Version |
---|---|
Java 1.0 | 45 |
Java 1.1 | 45 |
Java 1.2 | 46 |
Java 1.3 | 47 |
Java 1.4 | 48 |
Java 5 (JDK 5) | 49 |
Java 6 (JDK 6) | 50 |
Java 7 (JDK 7) | 51 |
Java 8 (JDK 8) | 52 |
Java 9 (JDK 9) | 53 |
Java 10 (JDK 10) | 54 |
Java 11 (JDK 11) | 55 |
Java 12 (JDK 12) | 56 |
Java 13 (JDK 13) | 57 |
Java 14 (JDK 14) | 58 |
Java 15 (JDK 15) | 59 |
Java 16 (JDK 16) | 60 |
Java 17 (JDK 17) | 61 |
Java 18 (JDK 18) | 62 |
Wrapping up...
The major version number will tell you which version of Java was used to compile the class file. If the major version is not recognized or is greater than the highest version listed here, it likely means that a more recent version of Java was used for compilation.
Comment your thoughts about javap below!
Discover more from 9Mood
Subscribe to get the latest posts sent to your email.
0 Comments