Class File Versions and Java Versions Mapping

Concept: Class File Versions and Java Versions

Purpose:

This note provides a reference for the mapping between Java class file versions and the corresponding Java versions. When compiling Java code, the compiled class files are assigned a version number that corresponds to the version of the Java compiler used. Ensuring compatibility between the Java version used to compile the code and the Java runtime used to execute it is crucial for avoiding runtime errors.

Key Idea:

Java class files are tagged with a version number that indicates which version of the Java compiler was used to create them. The Java runtime environment can only execute class files that were compiled using the same or an earlier version of the Java compiler.

Mapping of Class File Versions to Java Versions:

Class File VersionJava VersionNotes
45.0Java 1.1Initial class file version
46.0Java 1.2
47.0Java 1.3
48.0Java 1.4
49.0Java 5Introduced generics
50.0Java 6
51.0Java 7
52.0Java 8
53.0Java 9
54.0Java 10
55.0Java 11LTS (Long-Term Support)
56.0Java 12
57.0Java 13
58.0Java 14
59.0Java 15
60.0Java 16
61.0Java 17LTS (Long-Term Support)
62.0Java 18
63.0Java 19
64.0Java 20
65.0Java 21
66.0Java 22
67.0Java 23

Use Case:

Use this table to determine the class file version associated with a particular Java version when checking for compatibility issues between compiled code and runtime environments.