Reputation: 105
this afternoon I've finally completed my project in Java. So I decided to make it available for windows using launch4j to build the exe file.
Seemed something simple, but actually for me is not. My situation right now is the following:
java -jar "jar file path"
After describing you in the most detailed way my state, I want now to explicitly declare what I am aiming to:
Hope someone can give me support, cause this thing is driving my crazy since I've finished my project but still i can't deploy it officially
Upvotes: 0
Views: 4299
Reputation: 3154
I am install it from OpenJDK19U-jdk_x64_windows_hotspot_19.0.2_7.msi
.
jdeps -cp "lib\*" --module-path "lib\*" --multi-release 19 --print-module-deps --ignore-missing-deps you-app.jar
OR No dependency jar files:
jdeps --multi-release 19 --print-module-deps --ignore-missing-deps you-app.jar
Example Result:
java.base,java.desktop
jlink --add-modules java.base,java.desktop --output jdk-19-mini-jre --strip-debug --no-man-pages --no-header-files --compress=2
DemoApp
├── DemoApp.jar (your app jar)
├── demoapp.xml (Launch4j Config files)
└── jre (jlink command create JDK 19 jre)
C:\Users\IEUser\Downloads\DemoSwingApp\Output\DemoApp\demoapp.exe
C:\Users\IEUser\Downloads\DemoSwingApp\DemoApp\DemoApp.jar
GUI
jre
<?xml version="1.0" encoding="UTF-8"?>
<launch4jConfig>
<dontWrapJar>false</dontWrapJar>
<headerType>gui</headerType>
<jar>C:\Users\IEUser\Downloads\DemoSwingApp\DemoApp\DemoApp.jar</jar>
<outfile>C:\Users\IEUser\Downloads\DemoSwingApp\Output\DemoApp\demoapp.exe</outfile>
<errTitle></errTitle>
<cmdLine></cmdLine>
<chdir>.</chdir>
<priority>normal</priority>
<downloadUrl>http://java.com/download</downloadUrl>
<supportUrl></supportUrl>
<stayAlive>false</stayAlive>
<restartOnCrash>false</restartOnCrash>
<manifest></manifest>
<icon></icon>
<jre>
<path>jre</path>
<bundledJre64Bit>true</bundledJre64Bit>
<bundledJreAsFallback>true</bundledJreAsFallback>
<minVersion></minVersion>
<maxVersion></maxVersion>
<jdkPreference>jdkOnly</jdkPreference>
<runtimeBits>64/32</runtimeBits>
</jre>
</launch4jConfig>
Click Launch4j Build exe
Copy jre
to Output\DemoApp\jre
DemoSwingApp/Output
└── DemoApp
├── demoapp.exe
└── jre
Now, you can click demoapp.exe
You need pack DemoApp (include demoapp.exe + jre directory) to a zip.
Note: My example does not use a third-party jar. Only the App itself is packaged into a jar, and only Swing using the JDK.
Upvotes: 5