Java,UnsupportedClassVersionError. How can I solve this problem

I was doing my homework during the solar eclipse. It didn't report an error or even a warning When I tried to compile it from the terminal, I got the following error It runs through eclipse and compiles well I think it has something to do with the Java version? Solve it or try to bypass it anyway?

vedran@vedran-debian:~/java/oop/Aufgabe6$java Test 
Exception in thread "main" java.lang.UnsupportedClassVersionError: Test : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.urlclassloader.defineClass(urlclassloader.java:277)
    at java.net.urlclassloader.access$000(urlclassloader.java:73)
    at java.net.urlclassloader$1.run(urlclassloader.java:212)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.urlclassloader.findClass(urlclassloader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: Test. Program will exit.

Java version:

java version "1.6.0_23" 
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-1) 
OpenJDK 64-Bit Server VM (build 20.0-b11,mixed mode)

Edit:

Thank you for your explanation This seems to be a Java 6 / 7 problem I just compiled it in 1.6. It's like charm

Solution

Test. The class file has been compiled in Java 7 (major / minor version 51.0), so it is incompatible with the Java 6 (major / minor version 50.0) runtime Compile in Java 6 (or earlier) Java file, or run in Java 7 runtime class.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>