当前位置: 首页 > 知识库问答 >
问题:

Java Stacktrace错误不受支持主。次要版本51.0[重复]

裴俊智
2023-03-14

可能重复:
不支持主版本。次版本51.0

java.lang.UnsupportedClassVersionError: net/glitching/client : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main" 

这是什么意思?这是我的密码...

package net.glitching;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.Socket;

public class client {

    static Socket sock = null;

    public static void main(String[] args) {
        while (true) {
            try {
                sock = new Socket("localhost", 4000);
                ObjectInputStream in = new ObjectInputStream(sock.getInputStream());
            } 
            catch (IOException ex) {}
        }
    }

}

共有1个答案

戎洛华
2023-03-14

问题是您的SDK和运行时环境不匹配。试着检查compile选项以使用正确的版本,这两者都有。

另请参见:How to fix java.lang.UnsupportedClassVersionError:Unsupported Major.Minor version

 类似资料: