[Java] Find Java Version From Any Compiled Class Files

Learn how to easily identify the Java version from class files using the javap tool. 2 min


[Java] Find Java Version From Any Compiled Class Files
[Java] Find Java Version From Any Compiled Class Files
  • 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.

  1. Make sure any JDK version is installed in your machine first, then Open a command prompt or terminal window.
  2. Navigate to the directory where the class file is located using the cd command (change directory).
  3. 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 VersionMajor Version
Java 1.045
Java 1.145
Java 1.246
Java 1.347
Java 1.448
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!

adsense


Discover more from 9Mood

Subscribe to get the latest posts sent to your email.


Like it? Share with your friends!

What's Your Reaction?

Lol Lol
0
Lol
WTF WTF
0
WTF
Cute Cute
0
Cute
Love Love
0
Love
Vomit Vomit
0
Vomit
Cry Cry
0
Cry
Wow Wow
0
Wow
Fail Fail
0
Fail
Angry Angry
0
Angry
Rakshit Shah

Legend

Hey Moodies, Kem chho ? - Majama? (Yeah, You guessed Right! I am from Gujarat, India) 25, Computer Engineer, Foodie, Gamer, Coder and may be a Traveller . > If I can’t, who else will? < You can reach out me by “Rakshitshah94” on 9MOodQuoraMediumGithubInstagramsnapchattwitter, Even you can also google it to see me. I am everywhere, But I am not God. Feel free to text me.

0 Comments

Leave a Reply

Choose A Format
Story
Formatted Text with Embeds and Visuals
List
The Classic Internet Listicles
Ranked List
Upvote or downvote to decide the best list item
Open List
Submit your own item and vote up for the best submission
Countdown
The Classic Internet Countdowns
Meme
Upload your own images to make custom memes
Poll
Voting to make decisions or determine opinions
Trivia quiz
Series of questions with right and wrong answers that intends to check knowledge
Personality quiz
Series of questions that intends to reveal something about the personality
is avocado good for breakfast? Sustainability Tips for Living Green Daily Photos Taken At Right Moment