Home >Java >javaTutorial >How to Bundle a JRE with Launch4j for Standalone Java Applications?

How to Bundle a JRE with Launch4j for Standalone Java Applications?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-11-16 11:04:03288browse

How to Bundle a JRE with Launch4j for Standalone Java Applications?

Bundling a JRE with Launch4j

Launch4j offers a convenient feature for bundling a JRE within an executable file, but the documentation on this process is limited.

How to Bundle a JRE with Launch4j

  1. Acquire a Compact JRE: Obtain a portable JRE for execution. Oracle's download links primarily offer installer packages, requiring an alternative approach.
  2. Package as a Zip Archive: Create a zip file containing the following directory structure:

    • containerFolder

      • jre (Contains the copied JRE files: bin with java.exe, lib)
      • cfg (Optional for user configuration)
      • bin (Application files, including executable and JAR)
  3. Configure Launch4j XML: Specify the JRE's path in the Launch4j XML file:

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

Key Considerations:

  • The path in the XML points to the JRE folder, not the java.exe file. It should be one level above java.exe in the directory structure.
  • Utilize a pre-installed JRE from a Windows system to extract the necessary JRE files for bundling.

The above is the detailed content of How to Bundle a JRE with Launch4j for Standalone Java Applications?. 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