Thursday 24 September 2020

SOLVED- How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version

 

How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version

PROBLEM -

 Get this message, whenever we run my "Hello world" in Notepad++:

java.lang.UnsupportedClassVersionError: test_hello_world : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(Unknown Source) .........................................

A Java class file is a file (with the .class filename extension) containing Java bytecode that can be executed on the Java Virtual Machine (JVM). A Java class file is usually produced by a Java compiler from Java programming language source files (.java files) containing Java classes (alternatively, other JVM languages can also be used to create class files). If a source file has more than one class, each class is compiled into a separate class file. 

 

The reported major numbers are:

Java SE 14 = 58,
Java SE 13 = 57,
Java SE 12 = 56,
Java SE 11 = 55,
Java SE 10 = 54,
Java SE 9 = 53,
Java SE 8 = 52,
Java SE 7 = 51,
Java SE 6.0 = 50,
Java SE 5.0 = 49,
JDK 1.4 = 48,
JDK 1.3 = 47,
JDK 1.2 = 46,
JDK 1.1 = 45

1)  You should try to either run the Java code with a newer version of Java JRE.

 2) Specify the target parameter to the Java compiler to instruct the compiler to create code compatible with earlier Java versions.


For example, in order to generate class files compatible with Java 1.4, use the following command line:

javac -target 1.4 HelloWorld.java 

Newer versions of the Java compiler you are likely to get a warning about the bootstrap class  .

0 comments:

Post a Comment

 

Copyright @ 2013 Appychip.

Designed by Appychip & YouTube Channel