Javac 抛出不受支持的错误,而 Eclipse 工作正常
我尝试使用 cmd 提示符来执行我的 java 文件,但出现此错误,表示
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: MovingObject has been compiled by a more recent version of the Java Runtime (class file version 60.0), this version of the Java Runtime only recognizes class file versions up to 52.0
但是当我尝试在 eclipse 上执行我的 java 文件时,它工作得很好,只是我想尝试将其运行到命令提示符以查看是否两种方法都有效。尝试搜索这个问题,但大多数其他问题都是很久以前的事了。
I tried to use cmd prompt to execute my java file but I got this error that says
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: MovingObject has been compiled by a more recent version of the Java Runtime (class file version 60.0), this version of the Java Runtime only recognizes class file versions up to 52.0
but when I tried executing my java file on eclipse it works perfectly fine, its just that I want to try and run it to the command prompt to see if both ways works. Tried searching about the problem but most of the other problems is way back from long ago.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是我的计算机对于使用什么 JRE 感到困惑。我之前手动安装过JDK和JRE 8。
所以当我尝试通过cmd检查它时。
javac -version
是 Java 16,而
java -version
是 Java 8所以,我卸载了 Java 8,因为我在 eclipse 上安装了 JDK 16 和 JRE 版本 16,这让我很困惑我的电脑要使用什么版本。差不多就这样了。
The problem was that my computer was confused as to what JRE to use. I have manually installed JDK and JRE 8 before.
So when I tried checking it through cmd.
javac -version
is Java 16while,
java -version
is Java 8So, I uninstalled my Java 8 since I have installed JDK 16 and JRE version 16 on my eclipse which confuses my computer as to what version to use. That's pretty much it.