I package my application with jpackage and the resulting directory structure and config file looks correct.
19.11.2023 15.49 <DIR> app
19.11.2023 15.49 562 688 EazyCNC.exe
19.11.2023 15.49 <DIR> runtime
1 File(s) 562 688 bytes
4 Dir(s) 417 389 883 392 bytes free
Directory of C:\Users\nyholku\eazycnc-build\bundle\EazyCNC\app
19.11.2023 15.49 <DIR> .
19.11.2023 15.49 <DIR> ..
19.11.2023 15.49 262 .jpackage.xml
19.11.2023 15.49 385 091 commons-lang3-3.2.1.jar
19.11.2023 15.49 653 EazyCNC.cfg
19.11.2023 15.49 3 421 155 EazyCNC.jar
19.11.2023 15.49 4 928 humble-video-all-0.3.0.jar
19.11.2023 15.49 1 509 440 jna-5.6.0.jar
19.11.2023 15.49 2 735 878 jna-platform-5.6.0.jar
19.11.2023 15.49 11 712 967 jogamp-fat.jar
19.11.2023 15.49 65 966 json-20200518.jar
19.11.2023 15.49 195 713 miglayout-3.7.jar
19.11.2023 15.49 199 631 purejavacomm-1.0.1.x.jar
19.11.2023 15.49 118 138 purejavahidapi-0.0.13.jar
19.11.2023 15.49 127 628 vecmath.jar
13 File(s) 20 477 450 bytes
2 Dir(s) 417 401 921 536 bytes free
The app/EazyCNC.cfg looks like
[Application]
app.mainjar=$APPDIR\EazyCNC.jar
app.classpath=$APPDIR\commons-lang3-3.2.1.jar
app.classpath=$APPDIR\humble-video-all-0.3.0.jar
app.classpath=$APPDIR\jna-5.6.0.jar
app.classpath=$APPDIR\jna-platform-5.6.0.jar
app.classpath=$APPDIR\jogamp-fat.jar
app.classpath=$APPDIR\json-20200518.jar
app.classpath=$APPDIR\miglayout-3.7.jar
app.classpath=$APPDIR\purejavacomm-1.0.1.x.jar
app.classpath=$APPDIR\purejavahidapi-0.0.13.jar
app.classpath=$APPDIR\vecmath.jar
[JavaOptions]
java-options=-Djpackage.app-version=1.0
java-options=-Xmx1024m
java-options=-XX:+UseG1GC
java-options=-XX:MaxGCPauseMillis=50
java-options=-XX:+PrintGC
But when I try to launch it I get:
C:\Users\nyholku>eazycnc-build\bundle\EazyCNC\EazyCNC.exe
[0.004s][warning][gc] -XX:+PrintGC is deprecated. Will use -Xlog:gc instead.
[0.017s][info ][gc] Using G1
Error: Unable to initialize main class eazycnc.Main
Caused by: java.lang.NoClassDefFoundError: purejavahidapi/InputReportListener
But when I use javajvm directly I like this:
C:\Users\nyholku\eazycnc-build\bundle\EazyCNC>java -cp app/* eazycnc.Main
it works.
I build the app using ant as follows (I've included only the relevant bits):
<target name="jpackage-windows" if="is_windows" depends="init">
<exec executable="${jpackage}" dir=".">
<arg value="--win-console" />
<arg value="--type" />
<arg value="app-image" />
<arg value="--verbose" />
<arg value="--dest" />
<arg value="${bundle-dir}/" />
<arg value="--name" />
<arg value="EazyCNC" />
<arg value="--main-jar" />
<arg value="EazyCNC.jar" />
<arg value="--java-options" />
<arg value="-Xmx1024m -XX:+UseG1GC -XX:MaxGCPauseMillis=50 -XX:+PrintGC" />
<arg value="--resource-dir" />
<arg value="${resource-dir}" />
<arg value="--input" />
<arg value="${jpackage-input-dir}" />
<arg value="--runtime-image" />
<arg value="${java-runtime-dir}" />
<arg value="--temp" />
<arg value="${build-dir}/wix-tempfiles" />
</exec>
Some of the build variables are set like this:
<property name="app-image-type" value="exe" />
<property name="jdk-loc" value="C:\Program Files\Java\jdk-11" />
<property name="jpackage" value="C:\Program Files\Java\jdk-21\bin\jpackage.exe" />
<property name="jlink" value="C:\Program Files\Java\jdk-11\bin\jlink.exe" />
<property name="targetos" value="windows" />
<property name="pathsep" value=";" />
<property name="resource-dir" value="package-resources/windows" />
and some other vars have these values (from my ant output):
[echo] os.name : Windows 10
[echo] jdk-loc : C:\Program Files\Java\jdk-11
[echo] fxant-loc : ${fxant-loc}
[echo] basedir : C:\Users\nyholku\eazycnc-project
[echo] build-dir : C:\Users\nyholku/eazycnc-build
[echo] lib-dir : ./lib
[echo] src-dir : ./src
[echo] dist-dir : ./downloads
[echo] temp-dir : C:\Users\nyholku/eazycnc-build/temp-dir
[echo] classes-dir : C:\Users\nyholku/eazycnc-build/classes
[echo] eazycnc_version : 2.0.39
[echo] jpackage-input-dir: C:\Users\nyholku/eazycnc-build/jlink-input
I'm using the jpackage from jdk21 as jdk11 does not have it, but I would not think that is a problem.
I've been stuck at this for a day now, what am I missing?
Turns out that
just does not work for me. The resulting exe works but no classpaths apart from the main .jar seem to be set.
However
does work.