Javac 抛出不受支持的错误,而 Eclipse 工作正常

发布于 2025-01-16 22:58:05 字数 498 浏览 3 评论 0原文

我尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千と千尋 2025-01-23 22:58:05

问题是我的计算机对于使用什么 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 16

while, java -version is Java 8

So, 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文