简体   繁体   中英

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.

Apologies if you have already come across it, but you might find it useful to take a look at https://docs.oracle.com/javafx/2/deployment/jfxpub-deployment.htm

This guide provides basic and advanced information about building, packaging, and deploying your JavaFX application. JavaFX deployment requires no special code in your application and has many other differences from Java deployment. Even if you are an advanced Java developer, it is a good idea to review the Getting Started page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM