Home > Java > javaTutorial > How Can I Determine the JDK Version Used to Compile a .class File?

How Can I Determine the JDK Version Used to Compile a .class File?

Susan Sarandon
Release: 2024-12-08 10:00:20
Original
554 people have browsed it

How Can I Determine the JDK Version Used to Compile a .class File?

Determining the JDK Version Used to Compile a .class File

When debugging a "Bad version number in .class file" error in Java, it can be helpful to check the version of the .class files involved. Here's how to obtain this information:

Unix/Linux Environment:

Execute the following command:

javap -verbose MyClass | grep "major"
Copy after login

Windows Environment:

Run this command:

javap -verbose MyClass | findstr "major"
Copy after login

Interpreting the Output:

The output of these commands will include a line that contains "major": followed by a numerical value. This value represents the major version of Java used to compile the .class file:

Java Version Major Version
1.2 46
1.3 47
1.4 48
5 49
6 50
7 51
8 52
9 53
10 54
11 55
12 56
13 57
14 58
15 59
16 60
17 61
18 62
19 63
20 64

This information can help you determine the version mismatch between the JRE and JDK and adjust your compilation settings accordingly.

The above is the detailed content of How Can I Determine the JDK Version Used to Compile a .class File?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template