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"
Windows Environment:
Run this command:
javap -verbose MyClass | findstr "major"
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!