Missing JavaFX application class when using jPackage - java

I'm getting the message "Missing JavaFX application class com.ponderwhy.pikeinventory.PikeInventory" after deploying with jPackage.
Using AdoptOpenJDK 16, JavaFx-16, WiX 3.11 on Windows 10. My application runs fine when I use the following JVM options file.
# -classpath aka -cp
-cp D:/WS_Utility/PikeInventory/bin;D:/WS_Utility/Basic/bin;D:/WS_Utility/ancillary/bin;C:/Java/javafx-sdk-16/lib;C:/Java/controlsfx-jfx-13/controlsfx-11.0.2.jar
# -modulepath aka -p
-p C:/Java/javafx-sdk-16/lib;D:/WS_Utility/basic/bin;D:/WS_Utility/Ancillary/bin;D:/WS_Utility/PikeInventory/bin;C:/Java/controlsfx-jfx-13/controlsfx-11.0.2.jar
--add-modules=ALL-MODULE-PATH
--add-exports javafx.base/com.sun.javafx.collections=ALL-UNNAMED
--add-exports javafx.base/com.sun.javafx.runtime=ALL-UNNAMED
--add-exports javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED
--add-opens javafx.graphics/com.sun.javafx.css=ALL-UNNAMED
com.ponderwhy.pikeinventory.PikeInventory
When I use jPackage to build an.exe file using the following jPackage commands:
--type exe
--app-version 1.0.1
--description "Pike Inventory"
--name PikeInventory
--vendor PonderWhy
--verbose
--java-options -splash:$APPDIR//RockF7.jpg
--input D:/Dev/TrainInv/jPackage
--icon D:/Dev/TrainInv/jPackage/LocoFront.ico
--main-jar PikeInventory.jar
--main-class com.ponderwhy.pikeinventory.PikeInventory
--module-path C:/Java/javafx-jmods-16;C:/Java/controlsfx-jfx-13;C:/Java/JDK-16/jmods;D:/Dev/TrainInv/jPackage
--add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web
--win-console
--win-dir-chooser
--win-menu
--win-menu-group PikeInventory
--win-shortcut
# --win-upgrade-uuid PkInv
I have the 2 environment variables set that I find some references to.
PATH_TO_FX=C:\Java\javafx-sdk-16\lib
PATH_TO_FX_MODS=C:\Java\javafx-jmods-16
All three of my projects, Basic, Ancillary and PikeInventory have module-info.class.
The jPackage builds, deploys and installs without error. My splash comes up then the missing class message.
I am at a loss at what to try next to resolve my problem.
Any help would be greatly appreciated.
Peter

Related

java.lang.NoClassDefFoundError: javax/swing/SwingUtilities when app is packaged using jpackage

I'm creating a Kotlin compose app and I want to create a distributable package for Mac OS using jpackage (I know about the packageDmg Gradle task, but now I want to go around it).
The jar file works fine but the installed app crashes on start. By running the app from terminal (open /Applications/MyApp/Contents/MacOS/myapp) I found out that it throws this exception java.lang.NoClassDefFoundError: javax/swing/SwingUtilities
I've included all modules that the suggestRuntimeModules task suggested but it does not include anything that seems swing related to me.
I'm on an M1 mac with and java --version gives me this java 15.0.2 2021-01-19
Here is my packaging command:
jpackage --input ./ \
--name myApp \
--main-jar myapp-macos-x64-1.1.3.jar \
--type pkg \
--icon ../../../src/main/resources/icon.icns \
--app-version '1.1.3' \
--mac-package-name "My App" \
--vendor "My App" \
--add-modules java.instrument,java.net.http,java.prefs,java.sql,jdk.unsupported

What is the cause of io.netty.channel.StacklessClosedChannelException on deplyoment

So I'm developing a JavaFX app and when I run it on IntelliJ it works perfectly without any errors nor warnings but when I deploy it using Jpackage on sending WebSockets it throws the exception io.netty.channel.StacklessClosedChannelException
here's my Jpackage code
jpackage -t exe --name "App Name" --description "App Description" --app-version 1.1.0 --input input --dest output --icon favicon.ico --main-jar app.jar --module-path Path\to\javafx-jmods-17.0.1 --add-modules javafx.controls,javafx.base,javafx.graphics,javafx.web,javafx.fxml,java.sql,javafx.media --win-shortcut --win-menu --win-console
I tried narrowing the error down and it looks like its caused by ChannelFuture.sync() although this only occurs during packaging of the jar
Am I missing a java option or an export that I overlooked by mistake?
Any help would be appreciated, Thanks in advance.

Create a personalised JRE with Java 15 on Windows for Linux and Mac

I have found a way to create a personalised JRE on Windows that I can use on Windows.
I found a similar question on this web site where the answer
was "you just have to use the Linux jmods directory to make a Linux personalised JRE."
So, using AdoptOpenJDK (build 15+36), I tried to do that with the following commands:
jlink --module-path \jmodsWindows\ --add-modules java.desktop --output OUTWindows\java
jlink --module-path \jmodsLinux\ --add-modules java.desktop --output OUTLinux\java
jlink --module-path \jmodsMac\ --add-modules java.desktop --output OUTMac\java
But the personalised JREs that all three above commands created are the Windows one.
Is there something wrong with my commands? Is there a change in JDK 15 that affects how the jlink tool creates custom runtime images?
#deduper I tried with :
jlink --module-path C:\Users\hydrolien\Formiko\jmodsLinux --add-modules java.desktop --output OUTLinux\java
And that's working !
That was just a problem of absolute or relative path.
thanks a lot for your help !

Centos OpenJDK1.8 install OpenJFX

I have a docker image where the building process roughly looks like this:
FROM centos:latest
...
RUN yum install -y java-1.8.0-openjdk-devel
...
I highly depend on the specific java version, so changing that is not an option.
Right now I need to add openjfx to this and make it work, yet all the available documentation seems to be not working on my centos/openjdk combination.
Downloading the zip file and adding it to my container and running the following commands as described here:
RUN export PATH_TO_FX=/var/lib/javafx/lib \
&& javac --module-path $PATH_TO_FX --add-modules=javafx.controls HelloFX.java \
&& java --module-path $PATH_TO_FX --add-modules=javafx.controls HelloFX
Failes, as:
javac: invalid flag: --module-path
What would be the correct way to add it to this docker image?

java 9: JLink created invalid images - missing module executable script

I am creating a sample application with 3 modules user, dept and account. In my user module, I have a main class and compile my modules with the following command:
javac -d target --module-source-path src $(find -name "*.java")
After compiling, execute following command for run:
java -p target -m com.user/com.user.info.Launcher
The output after running java modules are successful. But when trying to create runtime image using jlink the image created successfully but module executable script is not there. For create an image, I am using the following command:
jlink --module-path $JAVA_HOME/jmods:target --add-modules com.user --output my-app
In, runtime image, I have bin directory, but this directory contains only java and keynote script. I am expecting user main class script as well, for executing my application.
My Java version as below:
java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+165)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+165, mixed mode)
How can I resolve this problem?
jlink creates a runtime VM image in which it includes only the modules that are needed.
Since you specified --add-modules com.user the image will include the com.user module, and all of the modules it (directly or indirectly) depends on.
You can run your application by using the java binary in the bin folder of the generated image, and using the command:
java com.user.info.Launcher
You can also have jlink generate a launcher script using the --launcher <command>=<module>/<main> option. In your case you could do something like:
jlink --module-path $JAVA_HOME/jmods:target --add-modules com.user --output my-app --launcher launch=com.user/com.user.info.Launcher
And after that, you can just use launch from the bin directory to run the application.

Categories

Resources