为什么最新的jre不能运行旧版本jdk编译的jar?

发布于 2025-01-18 13:29:15 字数 727 浏览 3 评论 0原文

我已经使用 VsCode 从我的 Java 项目创建了一个 Jar 文件,并且在我的电脑中完美运行。

我尝试使用一台没有任何 Java 的笔记本电脑来运行这样的 Jar;所以我刚刚下载并安装了最新版本的JRE(https://www.java. com/es/download/ie_manual.jsp),因为它是运行 .jar 所需的唯一东西

但是当我尝试在这台单独的笔记本电脑中运行 Jar 时,我收到一条毫无意义的错误消息,因为我创建一个使用旧版本的 JDK 打包并使用最新的 JRE 执行它应该可以工作。

我的JDK版本是这样的: 11.0.12(我使用“java -version”和“javac -version”得到相同的输出)

我在另一台电脑上的Jre版本是: “1.8.0_321”应该是最新版本。

我得到的错误如下: 版本不兼容导致的错误

有人遇到过这个错误吗?两个操作系统都是 Windows 10,当谷歌搜索特定错误时,我只是得到了解决方案,说 Java 具有向后兼容性,要实现 .bat,下载 JDK 并从那里开始工作。但我不明白为什么最新的 JRE 不能运行旧版本的 JDK(其中嵌入了 JRE 和编译器)。

I've used VsCode to create a Jar file from my Java Project and works perfectly in my pc.

I tried to use a laptop that had no Java whatsoever to run such Jar; so I just downloaded and installed the latest version of JRE(https://www.java.com/es/download/ie_manual.jsp) since it's the only thing required to run a .jar

But when I try to run the Jar in this separete laptop I get an error message that makes no sense, since I am creating a Jar with an old version of the JDK and executing it with the latest JRE it should work.

My version of JDK is this one:
11.0.12 (I get the same output with "java -version" and "javac -version")

My version of Jre in the other pc is:
"1.8.0_321" which is supossed to be the latest version.

And the error i get is the following:
Error due versions incompatibility

Has any one encountered this error? Both OS are Windows 10 and when googling for the specific error I just get solutions that say Java has backwards compatibility, to implement a .bat, download a JDK and work from there. But I don't understand why the latest JRE won't run an older version of JDK (which embeded has the JRE and compiler).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

万人眼中万个我 2025-01-25 13:29:15

blockquote我在另一台PC中的JRE版本是:“ 1.8.0_321”,它被置于最新版本。

1.8版本(JDK 8)不是最新版本。这是2014年的较旧版本。JDK11是2018年的新版本。最新版本是JDK 18的03.2022。

在这里,您可以从OpenJDK下载JDK 18:
https://jdk.java.net/18/

,从Oracle:
https://wwwww.oracle.com/java/java/java/technologies/technologies/downloads/

请注意,“ JRE”(JAVA RUNTIME ENVORENEMT)和“ JDK”(Java Development Kit)之间的分离由于JDK 9而不存在。现在只有JDK。

Blockquote My version of Jre in the other pc is: "1.8.0_321" which is supossed to be the latest version.

The 1.8 version (JDK 8) is not the latest. It's an older release from 2014. JDK 11 is a newer release from 2018. The latest release is JDK 18 from 03.2022.

Here you can download the JDK 18 from the OpenJDK:
https://jdk.java.net/18/

And here from Oracle:
https://www.oracle.com/java/technologies/downloads/

Also note that the separation between "JRE" (Java Runtime Environemt) and "JDK" (Java Development Kit) does not exist since JDK 9. Now there is only JDK.

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