JavaPackager icon indicating copy to clipboard operation
JavaPackager copied to clipboard

After packaging for macOS, the file "universalJavaApplicationStub" is missing in the MacOS directory within the app bundle, which causes the program to fail to launch.

Open wcxgit opened this issue 4 months ago • 0 comments

Problem Description

After packaging, the file "universalJavaApplicationStub" is missing in the MacOS directory within the macOS executable package, preventing the program from running properly.

Cause of the Problem

https://github.com/javapackager/JavaPackager/blob/master/src/main/java/io/github/fvarrui/javapackager/packagers/MacPackager.java


	private void processStartupScript() throws Exception {
		if (this.administratorRequired) {
			// We need a helper script ("startup") in this case,
			// which invokes the launcher script/ executable with administrator rights.
			// TODO: admin script depends on launcher file name 'universalJavaApplicationStub'

			// sets startup file
			this.executable = new File(macOSFolder, "startup");

			// creates startup file to boot java app
			VelocityUtils.render("mac/startup.vtl", executable, this);
		} else {
			File launcher = macConfig.getCustomLauncher();
			if (launcher != null && launcher.canRead() && launcher.isFile()){
				FileUtils.copyFileToFolder(launcher, macOSFolder);
				this.executable = new File(macOSFolder, launcher.getName());
			} else {
				this.executable = preparePrecompiledStartupStub();
			}
		}
		executable.setExecutable(true, false);
		Logger.info("Startup script file created in " + executable.getAbsolutePath());
	}

Configuration File

<plugin>
                <groupId>io.github.fvarrui</groupId>
                <artifactId>javapackager</artifactId>
                <version>1.7.6</version>
                <configuration>
                    <name>JavaVersionManage</name>
                    <bundleJre>true</bundleJre>
                    <mainClass>com.walter.javaversionmanage.Launcher</mainClass>
                    <generateInstaller>true</generateInstaller>
                    <platform>auto</platform>
                    <createZipball>true</createZipball>
                    <vmArgs>
                        <vmArg>-Xmx200m</vmArg>
                    </vmArgs>
                    <administratorRequired>true</administratorRequired>
                    <modules>
                        <module>java.naming</module>
                        <module>javafx.controls</module>
                        <module>javafx.fxml</module>
                        <module>java.sql</module>
                        <module>java.scripting</module>
                        <module>java.base</module>
                    </modules>
                </configuration>
                <executions>
                    <execution>
                        <id>bundling-for-mac</id>
                        <phase>package</phase>
                        <goals>
                            <goal>package</goal>
                        </goals>
                        <configuration>
                            <platform>mac</platform>
                            <createTarball>true</createTarball>
                            <macConfig>
                                <generateDmg>false</generateDmg>
                                <generatePkg>false</generatePkg>
                                <relocateJar>false</relocateJar>
<!--                                SCRIPT|UNIVERSAL|X86_64|ARM64-->
                                <macStartup>UNIVERSAL</macStartup>
                                <codesignApp>false</codesignApp>
                            </macConfig>
                            <additionalResources>
                                <additionalResource>src/main/resources/mac</additionalResource>
                            </additionalResources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Expected Result

It is expected that the "universalJavaApplicationStub" can be properly copied to the MacOS directory after packaging. May I ask if there is a fix plan for this issue?

wcxgit avatar Aug 31 '25 10:08 wcxgit