Home > Java > javaTutorial > How to Deploy a JavaFX 11 Desktop Application with a JRE Using Modern Modular Packaging?

How to Deploy a JavaFX 11 Desktop Application with a JRE Using Modern Modular Packaging?

Patricia Arquette
Release: 2024-12-20 07:31:09
Original
487 people have browsed it

How to Deploy a JavaFX 11 Desktop Application with a JRE Using Modern Modular Packaging?

Deploying a JavaFX 11 Desktop Application with a JRE

Modern Java Module-Based Packaging

Oracle's discontinuation of Java Web Start has necessitated developers to adopt new deployment mechanisms for JavaFX applications. Deploying JavaFX 11 applications involves bundling them with a JRE, following a modular approach.

Creating a Module Descriptor

The first step is to convert your application into a module by creating a module-info.java file with a unique module name.

module com.mcs75.businessapp {
    exports com.mcs75.desktop.businessapp;
    requires java.logging;
    requires transitive javafx.graphics;
    requires transitive javafx.controls;
}
Copy after login

Compiling, Packaging, and JMod Creation

Build using a module path instead of a classpath. Create a modular jar using the jar command. Then, create a jmod using the JDK's jmod tool.

javac -Xlint -g -d build/classes --module-path /opt/gluon-javafx/lib \
    src/java/com/mcs75/desktop/businessapp/*.java

jar -c -f build/mybusinessapp.jar -C build/classes .

jmod create --class-path build/mybusinessapp.jar \
    --main-class com.mcs75.desktop.businessapp.BusinessApplication \
    build/modules/mybusinessapp.jmod
Copy after login

Linking the Image

Finalize the deployment by assembling the modules and a minimal JRE using the jlink command.

jlink --output build/image \
    --module-path build/modules:/opt/gluon-javafx/lib \
    --add-modules com.mcs75.businessapp \
    --launcher MyBusinessApp=com.mcs75.businessapp
Copy after login

Distributing the Application

Package and distribute the entire image file tree as a zip or tar.gz. The executable script for users to run is located in the image's bin directory.

Cross-Platform Deployment

To create images for other platforms, specify the target platform in the jmod command using the --target-platform option and explicitly include the appropriate JDK's jmods directory.

This approach provides a modern and efficient way to deploy JavaFX 11 desktop applications with a JRE, without relying on discontinued technologies like Web Start.

The above is the detailed content of How to Deploy a JavaFX 11 Desktop Application with a JRE Using Modern Modular Packaging?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template