Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I bundle dependencies into exe? #462

Open
xmizore opened this issue Mar 17, 2025 · 2 comments
Open

Can I bundle dependencies into exe? #462

xmizore opened this issue Mar 17, 2025 · 2 comments

Comments

@xmizore
Copy link

xmizore commented Mar 17, 2025

I want to build a exe with no lib folder, I use maven-assembly-plugin and exe4j to build it successfully. Can I use JavaPackager to build it?

@xmizore
Copy link
Author

xmizore commented Mar 17, 2025

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
		 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.example</groupId>
	<artifactId>fx-build-test</artifactId>
	<version>1.0-SNAPSHOT</version>
	<name>fx-build-test</name>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<junit.version>5.9.2</junit.version>
		<mainClass>com.example.fxbuildtest.App</mainClass>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.openjfx</groupId>
			<artifactId>javafx-controls</artifactId>
			<version>21-ea+5</version>
		</dependency>
		<dependency>
			<groupId>org.openjfx</groupId>
			<artifactId>javafx-fxml</artifactId>
			<version>21-ea+5</version>
		</dependency>

		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter-api</artifactId>
			<version>${junit.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter-engine</artifactId>
			<version>${junit.version}</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.11.0</version>
				<configuration>
					<source>21</source>
					<target>21</target>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.openjfx</groupId>
				<artifactId>javafx-maven-plugin</artifactId>
				<version>0.0.8</version>
				<executions>
					<execution>
						<!-- Default configuration for running with: mvn clean javafx:run -->
						<id>default-cli</id>
						<configuration>
							<mainClass>com.example.fxbuildtest/com.example.fxbuildtest.HelloApplication</mainClass>
							<launcher>app</launcher>
							<jlinkZipName>app</jlinkZipName>
							<jlinkImageName>app</jlinkImageName>
							<noManPages>true</noManPages>
							<stripDebug>true</stripDebug>
							<noHeaderFiles>true</noHeaderFiles>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
				<configuration>
					<descriptorRefs>
						<descriptorRef>jar-with-dependencies</descriptorRef>
					</descriptorRefs>
					<archive>
						<manifest>
							<mainClass>${mainClass}</mainClass>
						</manifest>
					</archive>
				</configuration>
				<executions>
					<execution>
						<id>make-assembly</id>
						<phase>package</phase>
						<goals>
							<goal>single</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>io.github.fvarrui</groupId>
				<artifactId>javapackager</artifactId>
				<version>1.7.6</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>package</goal>
						</goals>
						<configuration>
							<!-- mandatory -->
							<mainClass>${mainClass}</mainClass>
							<!-- optional -->
							<bundleJre>true</bundleJre>
							<runnableJar>${build.directory}/${artifactId}-${version}-jar-with-dependencies.jar</runnableJar>
							<generateInstaller>false</generateInstaller>
							<administratorRequired>false</administratorRequired>
							<platform>windows</platform>
							<copyDependencies>false</copyDependencies>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>

emmm

[INFO]             Executing command: cmd.exe /s /c ""C:\Program Files\Java\jdk-21\bin\jdeps" -q --multi-release 21 --ignore-missing-deps --print-module-deps --add-modules=ALL-MODULE-PATH --module-path=C:\Users\sherl\Desktop\fx-build-test\target\fx-build-test-1.0-SNAPSHOT-jar-with-dependencies.jar;"
[ERROR]             Exception in thread "main" java.lang.module.FindException: Module javafx.base not found, required by javafx.controls
[ERROR]             	at java.base/java.lang.module.Resolver.findFail(Resolver.java:892)
[ERROR]             	at java.base/java.lang.module.Resolver.resolve(Resolver.java:192)
[ERROR]             	at java.base/java.lang.module.Resolver.resolve(Resolver.java:141)
[ERROR]             	at java.base/java.lang.module.Configuration.resolve(Configuration.java:420)
[ERROR]             	at java.base/java.lang.module.Configuration.resolve(Configuration.java:254)
[ERROR]             	at jdk.jdeps/com.sun.tools.jdeps.JdepsConfiguration$Builder.build(JdepsConfiguration.java:564)
[ERROR]             	at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.buildConfig(JdepsTask.java:607)
[ERROR]             	at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:561)
[ERROR]             	at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:537)
[ERROR]             	at jdk.jdeps/com.sun.tools.jdeps.Main.main(Main.java:50)

@xmizore
Copy link
Author

xmizore commented Mar 20, 2025

succeed when customizedJre is false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant