Checking the Version
When encountering the error, "Bad version number in .class file," it can be helpful to determine the version of the .class files in question. Here's a cross-platform approach to checking the major JDK version used to compile a .class file:
javap -verbose MyClass | grep "major"
javap -verbose MyClass | findstr "major"
Interpreting the Output
The output of the above command will include a line similar to:
major version: 50
This value corresponds to the major JDK version used to compile the .class file. Refer to the table below for a mapping between major version numbers and Java versions:
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 |
21 | 65 |
22 | 66 |
The above is the detailed content of How to Determine the JDK Version Used to Compile a .class File?. For more information, please follow other related articles on the PHP Chinese website!