简体   繁体   English

如何在 jre1.8 上运行 java11 和 jfx11 应用程序

[英]How to run java11 and jfx11 application on jre1.8

I am a computer student and I had during my internship in a company, develop a small java software using JavaFX, maven, and apache.poi.我是学计算机的,在公司实习期间,用JavaFX、maven、apache.poi开发了一个java的小软件。

Info: The application works on Intellij and builds perfectly, my problem concerns the *.jar that I generate once the project is finished.信息:该应用程序可在 Intellij 上运行并完美构建,我的问题涉及项目完成后生成的*.jar

I first used JDK 14 and JFX14, however at the time of the execution (java –jar xx.jar) I had an error saying that I was compiling the program in JAVA 58 (JAVA 14) and that I was using JRE 52 (JAVA 8).我首先使用 JDK 14 和 JFX14,但是在执行时 (java –jar xx.jar) 我有一个错误说我在 JAVA 58 (JAVA 14) 中编译程序并且我使用的是 JRE 52 (JAVA 8).

So I modified the project to compile with JDK 11 and JFX 11, and I now have the same error telling me that I am compiling the program in JAVA 55 (JAVA 11) and that I was using JRE 52 (JAVA 8).所以我修改了项目以使用 JDK 11 和 JFX 11 进行编译,现在我有同样的错误告诉我我正在 JAVA 55 (JAVA 11) 中编译程序并且我正在使用 JRE 52 (JAVA 8)。

The error comes from the fact that my PC uses jre1.8.0_251 by default.错误来自于我的电脑默认使用 jre1.8.0_251。

So I tried to launch the program in this way "path_to_jdk11 \ bin \ java.exe" -jar xxx.jar and it works.所以我尝试以这种方式启动程序 "path_to_jdk11 \ bin \ java.exe" -jar xxx.jar 并且它有效。

So that's my problem:这就是我的问题:

The majority of users use the version of JAVA offered on the Oracle site, ie jre1.8.0_251 which is the latest version available.大多数用户使用 Oracle 站点上提供的 JAVA 版本,即 jre1.8.0_251,这是可用的最新版本。 Outside my program requires Java 11, which is not deploying on corporate PCs, I imagine.在我的程序之外需要 Java 11,我想这不是部署在公司 PC 上。 I tried to port my project to java 8 but I have errors with Maven and the module.info.java.我试图将我的项目移植到 java 8,但 Maven 和 module.info.java 出现错误。

Do you have a tip for deploying the *.jar or deploying it in .exe so that it can run with a user who has jre1.8.0_251?您是否有部署*.jar或将其部署在.exe中以便它可以与拥有 jre1.8.0_251 的用户一起运行的提示?

Respectfully尊敬

Don't try to build a fat jar. It won't work with modern Java. Instead build a real installer.不要尝试构建一个胖子 jar。它不适用于现代 Java。而是构建一个真正的安装程序。 This can be done easily with JDK 14+.使用 JDK 14+ 可以轻松完成此操作。 Just follow this tutorial https://github.com/dlemmermann/JPackageScriptFX which covers everything you need.只需遵循本教程https://github.com/dlemmermann/JPackageScriptFX ,它涵盖了您需要的一切。 This uses jpackage from JDK 14 and some other tools from it and also works with non-modularized projects.这使用 JDK 14 的 jpackage 和它的一些其他工具,也适用于非模块化项目。 When you install JDK 14 just make sure you set JAVA_HOME and your PATH correctly so that all the tools find the correct version of Java for building.安装 JDK 14 时,只需确保正确设置 JAVA_HOME 和 PATH,以便所有工具都能找到正确版本的 Java 进行构建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM