Java错误 发生了JNI错误 在命令窗口中运行简单程序时

huangapple 未分类评论44阅读模式
英文:

Java error A JNI error has occurred occuring running simple program in the command window

问题

我正在Pluralsite上学习Java课程。第一个练习,当然是一个Hello World程序。我在我的IDE中使用Intellij IDEA。我根据模板编写了程序:

在此处查看代码

我在IDE中运行代码。没有问题。下一步是从命令提示符中运行它。根据课程,我将JRE中Java.exe的位置添加到了我的路径中。我重新启动了计算机以确保生效。我在程序所在的目录中以管理员身份打开命令提示符,然后输入"java -version",得到以下输出:

java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)

我输入"java Main",然后得到:

我输入"java Main",然后得到:
错误: 已发生JNI错误,请检查您的安装并重试
异常在线程"main"中: java.lang.UnsupportedClassVersionError: Main已由更高版本的Java运行时编译(class文件版本57.0),此版本的Java运行时只识别高达52.0的class文件版本

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)

运行环境:
jdk-14
jre 1.8.0_241

我已经卸载了所有Java相关内容,然后重新安装。我还卸载了IDE并重新安装。我在网上搜索了很多关于这个问题的信息,但没有解决。

另一位同事也在学习这门课程,遇到了同样的问题。

我会联系课程的负责人,但我想在他说"对我有效"之前,把这个问题提出来。哦,我使用的是Windows 10。

英文:

I'm taking a Java class on Pluralsite. The first exercise is, of course, an Hello World program. I'm using Intellij IDEA for my IDE. I write the program, from a template:

See code here

I run the code in the IDE. No problem. The next step is to run if from the command prompt. Per the class I put the location of the Java.exe in the JRE into my path. I reboot just to be sure. I open a command prompt as adminstrator in the directory where the program lives and start with "Java -version" and get

java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)

I type "Java Main" and I get:

I type "Java Main" and I get:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: Main has been compiled by a more recent version of the Java Runtime (class file version 57.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)

Running:
jdk-14
jre 1.8.0_241

I have uninstalled all things Java. Then reinstalled. I have uninstalled the IDE and reinstalled.
Googled all over about this, no joy.

Another co worker is taking the course, same thing,

I will reach out to the person conducting this, but wanted to get this question out there in case he says "Works for me". Oh, Windows 10.

huangapple
  • 本文由 发表于 2020年4月3日 23:08:33
  • 转载请务必保留本文链接:https://java.coder-hub.com/61014879.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定