I am trying to use Notepad++ as my all-in-one tool edit, run, compile, etc.
I have JRE installed, and I have setup my path variable to the .../bin
directory.
When I run my "Hello world" in Notepad++, I get this message:
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) .........................................
I think the problem here is about versions; some versions of Java may be old or too new.
PATH
variable in JRE or JDK?Class UnsupportedClassVersionErrorThrown when the Java Virtual Machine attempts to read a class file and determines that the major and minor version numbers in the file are not supported.
A Java class file holds the Java bytecode for a Java class that can be executed on a Java virtual machine (VM). Encoded at the beginning of a class file is a major and minor version number of the class file format that is used in it. This major. minor number indicates which Java VM can execute this class file.
1) If you encounter UnSupportedClassVersionError, check the JRE version you are using to run program and switch to higher version for quick solution.
The version number shown describes the version of the JRE the class file is compatible with.
The reported major numbers are:
Java SE 17 = 61, Java SE 16 = 60, Java SE 15 = 59, 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
(Source: Wikipedia)
To fix the actual problem you should try to either run the Java code with a newer version of Java JRE or 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
With newer versions of the Java compiler you are likely to get a warning about the bootstrap class path not being set. More information about this error is available in a blog post New javac warning for setting an older source without bootclasspath.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With