镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

How to share one jre in a system with many sub modules? #483

Open

Description

@meeterp

Problem to solve

How to share ../jre to run many sub modules?

Proposed solution

JavaPackager use launch4j to generate exe package, but can not pass configuration of launch4j to JavaPackager. if open the configuration of launch4j, this will is not a problem.

Alternatives considered

No response

Impact and scope

No response

JavaPackager version (if applicable)

1.7.6

Checklist

  • I searched for existing similar issues
  • I am willing to contribute a PR

Activity

  1. fvarrui commented on Oct 4, 2026

    @fvarrui
    Collaborator

    Thanks for the request! With Launch4j (the default exeCreationTool) this isn't possible today: JavaPackager builds the Launch4j config itself and the JRE path is either the bundled one or %JAVA_HOME%;%PATH%.

    It is possible with the Why launcher, overriding its config template. I've just tested this on Windows with 2.0.0-rc1:

    1. In each module, set exeCreationTool to why and bundleJre to false:

      <bundleJre>false</bundleJre>
      <winConfig>
          <exeCreationTool>why</exeCreationTool>
      </winConfig>
    2. Add assets/windows/why-ini.vtl to each module (or to your assetsDir), pointing jvm_install to the shared JRE, relative to the EXE's folder:

      mainclass=$info.mainClass
      #set($classpath = $info.jarFile.name)
      #foreach ($cp in $info.classpaths)
      #set($classpath = $classpath + ";" + $cp)
      #end
      classpath=${classpath}
      jvm_install=../jre
      allow_system_java=false
      allow_java_location_lookup=false
      check_main_class=false
      launch_options=${info.name}.l4j.ini
      

      Use forward slashes (../jre): with ..\jre Why finds the JVM but fails to start it.

    3. Put the shared JRE in jre, next to the modules' folders. You can create it with jlink, or package one module with bundleJre=true and customizedJre=false and move its jre folder.

    Keep in mind the installers won't include the shared JRE, as it's outside each app's folder, so you'd need to ship it yourself.

    I'll keep this open as an enhancement: an option to point the EXE to an external JRE that works with the three Windows launchers. Would that cover your case? Do you use the installers or just the app folders?

  2. added a commit that references this issue on Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfeedbackWaiting for feedback

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions