无法在使用jpackage创建exe后启动JVM。

huangapple go评论69阅读模式
英文:

Failed to launch JVM after using jpackage to create exe

问题

使用jpackage命令创建.exe文件后,运行该文件时出现错误Failed to launch JVM。更奇怪的是,我尝试了同样的命令(我保留了一个包含所有命令的文件,以便将来更容易使用)用于一个我知道之前可以正常工作的旧项目,因为几天前我制作了它,现在也出现了同样的错误。

我唯一能想到的更改是我从Windows 10切换到了Windows 11,但Eclipse正常运行,以及所有我的开发工具和过去制作的所有其他程序(它们应该正常运行,因为所有所需的文件都位于其文件夹中,jpackage的工作方式)。

运行该命令时,我没有收到任何错误,.exe文件已创建,安装没有任何问题。

可能的原因是什么,我应该怎么做?我看到了不同的帖子,有人建议那个人使用--win-console,并告诉他如果有任何输出的话,但如果我使用它而不是--win-menu,会打开一个终端窗口,然后立即关闭,没有任何输出。

英文:

After creating the .exe file using the command jpackage, I'm getting the error Failed to launch JVM when running the file. What is more weird is that I tried the same command (I keep a file with all the commands for easier use in future) for an older project that I know it was working because a few days ago I made it, and I'm now getting the same error.

The only change that I can think of is that I switched from Windows 10 to Windows 11, but Eclipse is running fine, as well as all my developing tools, and all the other programs that I made in the past (which they should, as all the required files are local to the their folder, the way jpackage works).

When running the command I'm not getting any errors, the .exe file is created and the installation doesn't have any problems.

What can be the cause of it and what should I do? I've seen a different thread and someone suggested to that person to use --win-console and to tell what he sees if anything, but if I use that instead of --win-menu, a terminal window is opened and closes without any output inside it.

jpackage -t exe --name "Exe Name"
--vendor "Vendor Name"
--app-version 1.0
--input "Location of the jar file"
--dest "Where the exe for installation to be placed, I normally use same as jar for organization reason"
--main-jar "Jar Name.jar"
--icon "Location of the icon file.ico"
--module-path "Where the jmods are located, downloaded from https://openjfx.io"
--add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web --win-shortcut --win-menu

答案1

得分: 0

你可以在运行jpackage之前手动执行jlink步骤;否则,jpackage在过程中会自动调用jlink。Jlink生成executable.exe,但jpackage为这个可执行文件创建安装程序,例如msi。

希望这个链接有用:
https://www.devdungeon.com/content/use-jpackage-create-native-java-app-installers#:~:text=jlink%20vs%20jpackage,-jlink%20was%20introduced&text=You%20can%20manually%20perform%20the,dmg%20%2C%20.

英文:

You can manually perform the jlink step before running jpackage; otherwise, jpackage automatically invokes jlink during the process. Jlink generates the executable.exe, but jpackage creates the installer for the executable, e.g. msi

I hope this link is useful:
https://www.devdungeon.com/content/use-jpackage-create-native-java-app-installers#:~:text=jlink%20vs%20jpackage,-jlink%20was%20introduced&text=You%20can%20manually%20perform%20the,dmg%20%2C%20.

答案2

得分: 0

我现在正在使用Eclipse Adoptium作为JDKJRE。我还从JavaFX Gluon网站下载了jmods。目前,我正在使用版本17,这是目前最长的LTS版本。

以下是我为使其工作所做的步骤:

  • 下载Eclipse Adoptium JDK和JRE,并安装它们(我选择了.msi版本);
  • 转到JavaFX Gluon并下载适合您版本的jmods(我选择将它们放在与JDK的其他jmods一起的地方(例如:C:\Program Files\Eclipse Adoptium\jdk-17.0.7.7-hotspot\jmods));
  • 安装它们后,进入系统变量并添加/更改JAVA_HOME以指向JDK文件夹(例如:C:\Program Files\Eclipse Adoptium\jdk-17.0.7.7-hotspot);
  • 进入系统变量 / Path并添加一个变量以指向文件夹:JDK\bin\server(例如:C:\Program Files\Eclipse Adoptium\jdk-17.0.7.7-hotspot\bin\server);
  • 运行jpackage命令时,按照以下示例操作:
jpackage -t exe
--name "应用程序名称"
--vendor "您的公司名称"
--app-version 1.0
--input "C:\Programs\Test program"
--dest "C:\Programs\Test program"
--main-jar "应用程序名称.jar"
--icon "C:\Programs\Test program\Application Name.ico"
--module-path "C:\Program Files\Eclipse Adoptium\jdk-17.0.7.7-hotspot\jmods"
--add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web,jdk.localedata
--win-shortcut --win-menu

希望这对那些遇到与我相同问题的人有所帮助,特别是在运行jpackage后出现无法启动JVM错误的情况。

英文:

I'm now using Eclipse Adoptium for both JDK as well as JRE. Also I downloaded the jmods from JavaFX Gluon website. Right now I'm using version 17 which has the longest LTS for now.

These are the steps that I did to make it work:

  • Download Eclipse Adoptium JDK, JRE and install them (I choose .msi versions);
  • Go to JavaFX Gluon and download the jmods for your version (I choose to place them together with the other jmods from the JDK (ex: C:\Program Files\Eclipse Adoptium\jdk-17.0.7.7-hotspot\jmods);
  • After installing them go to System variables and add/change JAVA_HOME to the JDK folder (ex: C:\Program Files\Eclipse Adoptium\jdk-17.0.7.7-hotspot);
  • Go to System variables / Path and add a variable to the folder: JDK\bin\server (ex: C:\Program Files\Eclipse Adoptium\jdk-17.0.7.7-hotspot\bin\server);
  • When running the jpackage command follow this example:
jpackage -t exe
--name "Application Name"
--vendor "Your company name"
--app-version 1.0
--input "C:\Programs\Test program"
--dest "C:\Programs\Test program"
--main-jar "Application Name.jar"
--icon "C:\Programs\Test program\Application Name.ico"
--module-path "C:\Program Files\Eclipse Adoptium\jdk-17.0.7.7-hotspot\jmods"
--add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web,jdk.localedata
--win-shortcut --win-menu

Hope this will help someone who had the same problem as my, and after running jpackage they were getting Failed to launch JVM error.

huangapple
  • 本文由 发表于 2023年2月27日 17:58:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/75578985.html
匿名

发表评论

匿名网友

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

确定