如何将 JRE 与 Launch4j 捆绑在一起?

发布于 2024-11-29 17:19:30 字数 169 浏览 8 评论 0原文

我的计算机上有 Launch4J,它是一个很棒的程序。我感兴趣的功能之一是能够将 JRE 捆绑到通用 .EXE 文件中。但是,我找不到任何描述如何执行此操作的文档。

如何将 JRE 与 EXE 捆绑在一起?另外,我从哪里可以获得一个紧凑、可移植的 JRE 来运行? Oracle 上的下载链接用于安装程序包。

I have Launch4J on my computer and it's a great program. One of its features I'm interested in is the ability to bundle a JRE in the general .EXE file. However, I can't find any documentation that describes how to go about doing this.

How do I bundle a JRE with the EXE? Plus, where do I get a compact, portable JRE to run? The download links on Oracle are for the installer packages.

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

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

发布评论

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

评论(7

赠佳期 2024-12-06 17:19:30

经过一番尝试,我终于找到了一种解决方法,将 jre 捆绑到我的应用程序中:

我将我的应用程序打包为 zip 文件,其中包含以下文件夹:

containerFolder
|- jre
      |-bin (in bin there is java.exe)
      |-lib
|- cfg (to save the user configuration, but it's not needed)
|- bin (my application with the .exe and the .jar and all the other stuff)

在 launch4j 的 xml 文件中,我像这样配置 jre:

<jre>
    <path>../jre</path>
    <opt>-DgvSIG.confDir=../cfg</opt>
</jre>

这里的技巧是路径不是java.exe 文件。 jre 的路径是相对于 .exe 的位置,它应该指向 java.exe 文件之前的一个文件夹。

我使用的 jre 文件夹只是 Windows 系统上安装的 jre 文件夹的复制和粘贴。

After some attempts i finally get a workaround to bundle the jre in my application:

I package my app as a zip file with the following folders inside:

containerFolder
|- jre
      |-bin (in bin there is java.exe)
      |-lib
|- cfg (to save the user configuration, but it's not needed)
|- bin (my application with the .exe and the .jar and all the other stuff)

In the xml file of launch4j i configure the jre like this:

<jre>
    <path>../jre</path>
    <opt>-DgvSIG.confDir=../cfg</opt>
</jre>

The trick here is that the path is not to the java.exe file. The path to the jre is relative to the position of the .exe and it should point to one folder before the java.exe file

The jre folder i'm using is just a copy&paste from the jre folder installed on a windows system.

万劫不复 2024-12-06 17:19:30

我做了以下操作,它使用 ver Launch4j 3.11 对我有用:

  1. 为我的应用程序创建了一个新文件夹(例如名为
    我的应用程序)。
  2. 将jar文件从java项目dist文件夹复制到MyApp
    以及 lib 文件夹。
  3. 在我的应用程序文件夹 MyApp 中创建了一个名为 jre 的文件夹
    所以现在 MyApp 文件夹包含:

    • MyApp.jar
    • lib <- 这包含我的 java 应用程序所需的库。
    • jre
  4. 从 java jre 文件夹(C:\Program
    Files (x86)\Java\jre7) to MyApp\jre
  5. 在Launch4j中设置了所有必需的选项,然后设置
    捆绑到“jre”的 JRE 路径

    Launch4j JRE options

  6. 确保在搜索选项中“仅使用私有 JDK 运行时”
    被选中。

I did the following and it worked for me using ver Launch4j 3.11:

  1. Created a new folder for my application (called for example
    MyApp).
  2. Copied the jar file from the java project dist folder to the MyApp
    along with the lib folder.
  3. Created a folder called jre in my application folder MyApp
    so now MyApp folder contains:

    • MyApp.jar
    • lib <- this has the libraries needed by my java app.
    • jre
  4. Copied the bin and lib folders from java jre folder (C:\Program
    Files (x86)\Java\jre7) to MyApp\jre
  5. In the Launch4j having set all the required options, then set the
    Bundled JRE path to "jre"

    Launch4j JRE options

  6. Make sure that in the search options "Only use private JDK runtimes"
    is selected.
你丑哭了我 2024-12-06 17:19:30

和你哥一样的问题。现在不用担心了。一切都以最大深度来解决,以解决未来的解决方案。
解决如何将 JRE 捆绑到 jar 中而无需用户安装 java 的问题。您的 Java 应用程序将运行。

  1. libbin 文件夹从 JRE 文件夹复制到项目 dist 文件夹

jar to exe conversion

  1. 打开 launch4j 并输入以下设置。
    输入图像描述这里

技巧是您需要提供包含 javaw.exe 的完整路径。

享受!!!!

The same problem like you mate. No worries now. Its all solve with the maximum depth to solve future solution.
Solution how you can bundle your JRE for your jar without the need that the user has to install java or not. Your java application will run.

  1. Copy lib and bin folder from your JRE folder to your project dist folder

jar to exe conversion

  1. open launch4j and enter the following setting.
    enter image description here

The trick is you need to give the full path to the including javaw.exe.

Enjoy!!!!

溇涏 2024-12-06 17:19:30

上面提到的答案对我不起作用。我正在使用 JDK 20。我做了什么:

  1. 创建了我的 Jar 文件
  2. 为应用程序创建一个文件夹 appFolder
  3. 将 jar 文件放入 appFolder
  4. 创建了 myJdk > 文件夹中的appFolder
  5. 将我机器上JDK的内容放在appFolder中的myJdk文件夹中
  6. 设置路径为将 JRE(在我的例子中为 JDK)捆绑到 myJdk/bin,这是相对于 appFolder 的。

一个简单的文件夹视图:

appFolder
|- myJdk
   |- all contents from my jdk folder, installed on the machine. (The only folder I could remove was the jmods. All the rest were needed)
|- jar file

The mentioned answers above did not work for me. I am using JDK 20. What I did:

  1. Created my Jar file
  2. Create a folder for the application appFolder
  3. Put the jar file in appFolder
  4. Created a myJdk folder in the appFolder
  5. Put the contents of the JDK on my machine in the myJdk folder in the appFolder
  6. Set the path to the bundled JRE(JDK in my case) to myJdk/bin, which is relative to the appFolder.

A simple folder view:

appFolder
|- myJdk
   |- all contents from my jdk folder, installed on the machine. (The only folder I could remove was the jmods. All the rest were needed)
|- jar file
忆梦 2024-12-06 17:19:30

我刚刚做了这个。上面清楚的描述了捆绑jre的方法。

在这里,我只是分享一个我曾经奋斗过的经历。如果您想在通过launch4j创建wrapper exe后创建安装程序exe,请注意launch4j和jre的文件路径。这是我用来解决问题的路径:

launch4j、bin/jre、resources/bin/jre。

launch4j、bin 和 resources 处于同一级别。

I have just done this. Above clearly describe the method for bundling jre.

Here, I just share an experience that I have struggled. If you want to create an installer exe after created wrapper exe by launch4j, pay attention to the file path for launch4j and jre. This is my path I used to solve my issues:

launch4j, bin/jre, resources/bin/jre.

launch4j, bin, and resources are at same level.

落花浅忆 2024-12-06 17:19:30

jre 通常可以在您的 SDK 文件夹中找到。是的,在线链接是安装程序,但安装后,JRE 现在位于您的本地磁盘上。我的位于

${jdk folder}\jre

您不需要的 JRE 部分,如果您确实需要,可以手动删除(我不确定网上有什么)。

The jre can usually be found in your SDK folder. Yes the links online are installers, but once it installs, the JRE is now located on your local disk. Mine is located in

${jdk folder}\jre

The parts that you don't need from the JRE could probably be removed manually if you really wanted (I'm not sure whats available online).

‘画卷フ 2024-12-06 17:19:30

使用 Launch4J 将 Java 应用程序与特定 JRE 捆绑在一起的工作示例可以在 https://github.com/vZome/vzome/blob/master/desktop/platform/windows/README.md。此特定发行版配置为要求 vZome 才能使用 < strong>捆绑的 JRE,而不是目标平台上找到的任何 JRE。

希望这有帮助。

A working example of using Launch4J to bundle a Java application with a specific JRE can be found at https://github.com/vZome/vzome/blob/master/desktop/platform/windows/README.md. This particular distribution is configured to require vZome to use the bundled JRE rather than any JRE found on the target platform.

Hope this helps.

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