在运行glassfish 6.2.0的IDEA中输入java.lang.不支持的类版本错误

s6fujrry  于 2023-01-25  发布在  Java
关注(0)|答案(1)|浏览(153)

我正在使用IDEA来做一些关于JSF的任务,我只是用glassfish运行一个简单的项目,输出如下:
the out put

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/glassfish/admin/cli/AsadminMain has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    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$100(Unknown Source)
    at java.net.URLClassLoader$1.run(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)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

我在谷歌上搜索了一下,知道52版是jdk8,所以我删除了所有其他的jdk,只留下jdk8,版本确实是1.8:
the java version

C:\Users\42173>java -version
java version "1.8.0_291"
Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)

C:\Users\42173>javac -version
javac 1.8.0_291

但它仍然显示相同的错误,我不知道该怎么办。
而且我已经试过glassfish5,但输出仍然有错误:
exception with glassfish5

[2021-06-18 11:14:13,323] Artifact untitled1:war exploded: Artifact is being deployed, please wait...
[2021-06-18 11:14:13,818] Artifact untitled1:war exploded: Error during artifact deployment. See server log for details.
[2021-06-18 11:14:13,818] Artifact untitled1:war exploded: java.io.IOException: com.sun.enterprise.admin.remote.RemoteFailureException: Error occurred during deployment: Exception while deploying the app [untitled1_war_exploded] : A MultiException has 4 exceptions.  They are:
1. java.lang.IllegalAccessError: tried to access class sun.security.provider.SunEntries from class com.sun.crypto.provider.SunJCE
2. java.lang.IllegalStateException: Unable to perform operation: post construct on com.sun.enterprise.security.ssl.SSLUtils
3. java.lang.IllegalArgumentException: While attempting to resolve the dependencies of com.sun.enterprise.security.SecurityLifecycle errors were found
4. java.lang.IllegalStateException: Unable to perform operation: resolve on com.sun.enterprise.security.SecurityLifecycle
. Please see server.log for more details.
bfrts1fy

bfrts1fy1#

你把错误信息搞错了。

... has been compiled by a more recent version of the Java Runtime (class file version 55.0),
this version of the Java Runtime only recognizes class file versions up to 52.0

它没有告诉您需要Java 8,而是告诉您Java 8(类版本52)太旧,无法运行由版本55(即Java 11)编译的类。
所以需要安装JDK 11。

相关问题