Experiments with JavaFX
Find a file
2025-11-14 22:24:41 +01:00
src Fix warnings (unnamed parameter, @Temporal) 2025-11-14 22:24:41 +01:00
.gitignore Fix dependency conflict in hibernate-core 2025-02-28 22:44:32 +01:00
build-jlink.sh Rename target dirs 2023-04-07 01:46:18 +02:00
build-jpackage.sh Add jpackage 2023-04-07 19:47:01 +02:00
LICENSE Upgrade to JavaFX 18, add stuff from sample-ratpack 2022-03-12 22:25:48 +01:00
pom.xml Cleanup dependencyManagement 2025-11-14 18:54:39 +01:00
README.md Document issue with Maven 3.9.7 2024-06-15 19:57:03 +02:00
renovate.json Add renovate.json 2023-09-19 21:05:09 +00:00
run-cp.cmd Add support for Windows 2023-04-06 21:51:13 +02:00
run-cp.sh Use assembly plugin for packaging 2023-03-08 20:32:06 +01:00
run.cmd Add support for Windows 2023-04-06 21:51:13 +02:00
run.sh Use assembly plugin for packaging 2023-03-08 20:32:06 +01:00

sample-javafx

Experiments with JavaFX

Run Standalone

Linux / MacOS:

$ mvn clean verify

$ java \
  -p target/sample-javafx-*-dist/lib/ \
  --add-modules ALL-MODULE-PATH \
  -Dapp.jdbc.url=jdbc:h2:./databases/task-db \
  com.github.phoswald.sample.Application

$ java \
  -cp $(echo target/sample-javafx-*-dist/lib)/"*" \
  -Dapp.jdbc.url=jdbc:h2:./databases/task-db \
  com.github.phoswald.sample.ApplicationLauncher

$ APP_JDBC_URL=jdbc:h2:./databases/task-db \
  target/sample-javafx-*-dist/bin/run.sh

$ APP_JDBC_URL=jdbc:h2:./databases/task-db \
  target/sample-javafx-*-dist/bin/run-cp.sh

Windows:

$ mvn clean verify

$ java ^
  -p target\sample-javafx-1.0.0-SNAPSHOT-dist\lib ^
  --add-modules ALL-MODULE-PATH ^
  -Dapp.jdbc.url=jdbc:h2:%USERPROFILE%\Documents\databases\task-db ^
  com.github.phoswald.sample.Application

$ java ^
  -cp target\sample-javafx-1.0.0-SNAPSHOT-dist\lib\* ^
  -Dapp.jdbc.url=jdbc:h2:%USERPROFILE%\Documents\databases\task-db ^
  com.github.phoswald.sample.ApplicationLauncher

$ set APP_JDBC_URL=jdbc:h2:%USERPROFILE%\Documents\databases\task-db
$ target\sample-javafx-1.0.0-SNAPSHOT-dist\bin\run.cmd
$ target\sample-javafx-1.0.0-SNAPSHOT-dist\bin\run-cp.cmd
$ set APP_JDBC_URL=

Linux / MacOS:

$ mvn clean verify && ./build-jlink.sh

$ target/manual-jlink/bin/java --list-modules
$ ls -la target/manual-jlink/lib/jars 

$ APP_JDBC_URL=jdbc:h2:./databases/task-db \
  target/manual-jlink/bin/run.sh

The maven-jlink-plugin cannot be used because jlink cannot process automatic modules (see special handling in build-jlink.sh).

Run executable and JRE created by JPackage

Linux / MacOS:

$ mvn clean verify && ./build-jlink.sh && ./build-jpackage.sh

$ ls -la target/manual-jpackage/sample-javafx/lib/app/

$ APP_JDBC_URL=jdbc:h2:./databases/task-db \
  target/manual-jpackage/sample-javafx/bin/sample-javafx

The jpackage-maven-plugin does not work because automatic modules cannot be processed and are ignored (see special handling in build-jpackage.sh).

Run from Eclipse

The application can be started from Eclipse in a non-modular way.

Module Path vs. Class Path

  • By default, the org.openjfx:* dependencies should be specified as modules on the module path (using the -p und --add-modules options).
  • It is possible, although not officially supported, to run the application in a non-modular way from the class path (using only the -cp option). For that, the main class must not extend javafx.application.Application (see the additional main class ApplicationLauncher, which simply delegates to Application).

Issues with profiles and classifiers in Maven

Maven 3.9.7 does not correctly set the property javafx.platform from profiles of org.openjfx:javafx. Manually setting it to linux works from the CLI, but not within Eclipse.