gpt4 book ai didi

java - 发生 JNI 错误(java 通过 cmd)

转载 作者:行者123 更新时间:2023-11-30 05:31:55 25 4
gpt4 key购买 nike

我使用记事本编写了一个“Helloworld.java”文件。我通过编写“javac Helloworld.java”在cmd上进行编译,在同一目录中得到了“Helloworld.class”文件。

我编写了“java Helloworld”来启动它,但发生了 JNI 错误。

我检查了我的java版本,没有找到原因。我该如何解决这个问题?

C:\Users\chan5\OneDrive\문서\Java_tutorials>java -version java version "1.8.0_201" Java(TM) SE Runtime Environment (build 1.8.0_201-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

我将 java-bin 的路径添加到系统的路径列表中。

下面是我的 cmd 屏幕:

C:\Users\chan5\OneDrive\문서\Java_tutorials>dir/w C 드라이브의 볼륨에는 이름이 없습니다. 볼륨 일련 번호: 68B8-C9E4

C:\Users\chan5\OneDrive\문서\Java_tutorials 디렉터리

[.] [..] Helloworld.class Helloworld.java 2개 파일 542 바이트 2개 디렉터리 120,717,078,528 바이트 남음

C:\Users\chan5\OneDrive\문서\Java_tutorials>java Helloworld
Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.UnsupportedClassVersionError:
Helloworld has been compiled by a more recent version of the Java Runtime (class file version 56.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)

C:\Users\chan5\OneDrive\문서\Java_tutorials>

最佳答案

注意这一行:

Helloworld has been compiled by a more recent version of the Java Runtime (class file version 56.0)

您似乎已使用 Java 12 进行编译,但正在尝试使用 Java 8 运行。

关于java - 发生 JNI 错误(java 通过 cmd),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57350699/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com