'How to deploy a self-contained JavaFX application without using Maven/Gradle/IDEs?

I'm working on a simple JavaFX project using: Windows, VSCode/PowerShell, Java SDK 17.0.2, JavaFX SDK 17.0.2.

Here is my project structure:

bin/
    snaptools/
        Controller.class
        Main.class
        SnapTransceiver.class
        icon.png
        snaptools.fxml
lib/
    openjfx-17.0.2_windows-x64_bin-sdk/
        ...
    jSerialComm-2.9.1.jar
    snaprotocol-1.0.0.jar
src/
    snaptools/
        Controller.java
        Main.java
        SnapTransceiver.java
        icon.png
        snaptools.fxml

I can compile the project using this command line:

javac -encoding UTF-8 -d bin --class-path "lib/jSerialComm-2.9.1.jar;lib/snaprotocol-1.0.0.jar" --module-path lib/openjfx-17.0.2_windows-x64_bin-sdk/javafx-sdk-17.0.2/lib --add-modules javafx.controls,javafx.fxml src/snaptools/*.java

I can run the program using this command line:

java --class-path "bin;lib/jSerialComm-2.9.1.jar;lib/snaprotocol-1.0.0.jar" --module-path lib/openjfx-17.0.2_windows-x64_bin-sdk/javafx-sdk-17.0.2/lib --add-modules javafx.controls,javafx.fxml snaptools.Main

My project is pretty much done. I just need to package it. Unfortunately, it seems everybody is using Maven/Gradle and IDE-specific tricks (Eclipse, NetBeans, IntelliJ). I don't want to depend on these methods.

What I want:

  • An executable .exe file without installation process (one big file that only executes and preferably extracts nothing).
  • Without using Maven/Gradle (I'll probably put everything in a makefile).
  • Without the need of using a specific IDE (I use VSCode, but I don't want to depend on it either).
  • Can be done by command lines on a regular terminal.
  • Contain everything it needs to execute (user doesn't need to install anything).

Is it possible? Btw, I've also been messing with Launch4j, jpackage, and jlink, but couldn't figure it out.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source