简体   繁体   English

launch4j exe找不到jre

[英]launch4j exe can't find jre

Issues with launch4j launch4j 的问题

Program consists on one uber jar via maven-shade plugin and a Data/ Runs fine on any jre7 machine, windows or linux程序由一个 uber jar 组成,通过 maven-shade 插件和一个数据/在任何 jre7 机器上运行良好,windows 或 linux

However I've been unable to get launch4j to work.但是我一直无法让 launch4j 工作。

launch4j config.xml: launch4j config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<launch4jConfig>
  <dontWrapJar>false</dontWrapJar>
  <headerType>gui</headerType>
  <jar>pllsolver-0.2alpha.jar</jar>
  <outfile>pllsolver-0.2alpha.exe</outfile>
  <errTitle>NO JRE FOUND</errTitle>
  <cmdLine></cmdLine>
  <chdir></chdir>
  <priority>normal</priority>
  <downloadUrl>http://java.com/download</downloadUrl>
  <supportUrl></supportUrl>
  <stayAlive>false</stayAlive>
  <manifest></manifest>
  <icon>sicr.ico</icon>
  <jre>
    <path>jre7</path>
    <bundledJre64Bit>false</bundledJre64Bit>
    <minVersion></minVersion>
    <maxVersion></maxVersion>
    <jdkPreference>preferJre</jdkPreference>
    <runtimeBits>64/32</runtimeBits>
  </jre>
  <splash>
    <file>sicr.bmp</file>
    <waitForWindow>false</waitForWindow>
    <timeout>5</timeout>
    <timeoutErr>true</timeoutErr>
  </splash>
  <messages>
  </messages>
</launch4jConfig>

Then to build, on windows, I try this:然后在 windows 上构建,我试试这个:

PS K:\test> set PATH="K:\test\jre7\bin\"
PS K:\test> ..\launch4j\launch4jc.exe .\config.xml
launch4j: Compiling resources
launch4j: Linking
launch4j: Wrapping
launch4j: Successfully created K:\test\.\pllsolver-0.2alpha.exe
PS K:\test> .\pllsolver-0.2alpha.exe
PS K:\test>

It's at this point that I get a nice little window about how it failed to find the JRE.正是在这一点上,我得到了一个很好的小 window 关于它如何找不到 JRE。

Java is in K:\test\jre7\bin\java.exe My jar is K:\test\pllsolver-0.2alpha.jar Java 在 K:\test\jre7\bin\java.exe 我的 jar 在 K:\test\pllsolver-0.2alpha.jar

Additionally, I don't know if this will be an issue yet, but the executable and the Data/ need to be in the same directory.此外,我不知道这是否会成为一个问题,但可执行文件和 Data/ 需要位于同一目录中。 I'm planning to do better pathing later but I don't have a clear understanding of Windows ENV variables.我打算稍后做更好的路径,但我对 Windows ENV 变量没有清楚的了解。

a bit late but maybe it can still help you ...有点晚了,但也许它仍然可以帮助你......

One thing which works for sure with launch4j and JRE is to bundle the JRE in the folder of your application.对 launch4j 和 JRE 肯定有效的一件事是将 JRE 捆绑在应用程序的文件夹中。

To do so:这样做:

  • create a path 'jre' in the folder with your '*.exe'使用“*.exe”在文件夹中创建路径“jre”
  • copy a JRE in this folder (this jre has to fit the 'min'/'max' conditions you have set)在此文件夹中复制一个 JRE(此 JRE 必须符合您设置的“最小”/“最大”条件)
  • set '<path>/jre</path>' inside the <jre> configuration of your '.xml'在 '.xml' 的 <jre> 配置中设置 '<path>/jre</path>'

... this should work ......这应该有效

I struggled around with the JRE setting using launch4j 3.12 (2020) and OpenJDK and got also the message "no java runtime found".我在使用 launch4j 3.12 (2020) 和 OpenJDK 的 JRE 设置方面苦苦挣扎,并且还收到消息“未找到 Java 运行时”。 My target, was to use OpenJDK ( https://adoptopenjdk.net/ ) Two ways were successful:我的目标是使用 OpenJDK ( https://adoptopenjdk.net/ ) 两种方法都成功了:

  1. Install OpenJDK, with the JavaSoft (Oracle) registry keys activated and select the "only use public JREs" launch4j-option.安装 OpenJDK,激活 JavaSoft (Oracle) 注册表项并选择“仅使用公共 JRE”launch4j 选项。
  2. Install OpenJDK, with the JAVA_HOME option set, and set the "bundled jre path" in the JRE tab to %JAVA_HOME% (xml content: %JAVA_HOME%) With this you are able to use different JRE for different applications setting the JAVA_HOME variable for each of the differently.安装 OpenJDK,设置 JAVA_HOME 选项,并将 JRE 选项卡中的“捆绑的 jre 路径”设置为 %JAVA_HOME%(xml 内容:%JAVA_HOME%)这样您就可以为不同的应用程序使用不同的 JRE 设置 JAVA_HOME 变量每一个都不同。

It appears to be that launch4j is looking for the JRE path relative to its 'outfile' location.看起来 launch4j 正在寻找相对于其“outfile”位置的 JRE 路径。

Solutions:解决方案:

  • You can use an absolute path eg 'C:\\loc\\of\\jre'您可以使用绝对路径,例如 'C:\\loc\\of\\jre'
  • Put your JRE in your 'outfile' directory and set the JRE path relatively eg 'jre'将您的 JRE 放在您的“outfile”目录中,并相对设置 JRE 路径,例如“jre”
  • Treat the JRE path as relative to the 'outfile' directory eg '....\\somefolder\\jre'将 JRE 路径视为相对于 'outfile' 目录,例如 '....\\somefolder\\jre'

My launch4j version: 3.14我的launch4j版本:3.14

This fixed it for me.这为我修好了。 The %PATH% was missing %PATH%丢失

<jre>
    <path>%JAVA_HOME%;%PATH%</path>
    <requiresJdk>false</requiresJdk>
    <requires64Bit>false</requires64Bit>
    <minVersion></minVersion>
    <maxVersion></maxVersion>
  </jre>

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

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