Home  >  Article  >  Java  >  How Can I Bundle a JRE with My Application Using Launch4j?

How Can I Bundle a JRE with My Application Using Launch4j?

Susan Sarandon
Susan SarandonOriginal
2024-11-25 03:03:11907browse

How Can I Bundle a JRE with My Application Using Launch4j?

Bundling a JRE with Launch4j: A Comprehensive Guide

Enhancing application portability by bundling a JRE within the executable file is a key feature of Launch4j. To achieve this, follow these steps:

Acquiring a Portable JRE:

Oracle's JRE download links provide installer packages. To obtain a compact, portable JRE, navigate to other sources such as third-party websites or online repositories.

Integrating JRE with the EXE:

To bundle the JRE with the EXE using Launch4j, adopt the following structure within a zip file:

containerFolder
|- jre
      |-bin (java.exe resides within)
      |-lib
|- cfg (optional configuration folder)
|- bin (application with .exe, .jar, and dependencies)

Launch4j XML Configuration:

Within the Launch4j XML file, specify the JRE path relative to the EXE's location:

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

Path Considerations:

Note that the "path" attribute does not point directly to "java.exe." Instead, it refers to the folder that contains it, ensuring proper JRE integration.

Custom JRE:

For bundling, you can use a JRE extracted from a Windows system installation. Simply copy and paste the necessary files into the "jre" folder.

The above is the detailed content of How Can I Bundle a JRE with My Application Using Launch4j?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Is `i ` Atomic in Java?Next article:Is `i ` Atomic in Java?