List of Java class file format major version numbers?

ID : 10463

viewed : 25

Tags : javaversionjava

Top 5 Answer for List of Java class file format major version numbers?

vote vote

97

These come from the class version. If you try to load something compiled for java 6 in a java 5 runtime you'll get the error, incompatible class version, got 50, expected 49. Or something like that.

See here in byte offset 7 for more info.

Additional info can also be found here.

vote vote

90

I found a list of Java class file versions on the Wikipedia page that describes the class file format:

http://en.wikipedia.org/wiki/Java_class_file#General_layout

Under byte offset 6 & 7, the versions are listed with which Java VM they correspond to.

vote vote

77

Official source for major version number:

Java Virtual Machine Specification, Chapter 4. The class File Format

The latest published version of the JVM spec can be found here.

vote vote

68

If you're having some problem about "error compiler of class file", it's possible to resolve this by changing the project's JRE to its correspondent through Eclipse.

  1. Build path
  2. Configure build path
  3. Change library to correspondent of table that friend shows last.
  4. Create "jar file" and compile and execute.

I did that and it worked.

vote vote

58

If you have a class file at build/com/foo/Hello.class, you can check what java version it is compiled at using the command:

javap -v build/com/foo/Hello.class | grep "major" 

Example usage:

$ javap -v build/classes/java/main/org/aguibert/liberty/Book.class | grep major   major version: 57 

According to the table in the OP, major version 57 means the class file was compiled to JDK 13 bytecode level

Top 3 video Explaining List of Java class file format major version numbers?

Related QUESTION?