badvision / jace

Java Apple Computer Emulator
Apache License 2.0
66 stars 19 forks source link

Cannot build (no javafx) #40

Closed ericscharff closed 4 months ago

ericscharff commented 3 years ago

JavaFX appears to have been removed from OpenJDK 11 which means jace doesn't build, with errors such as

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/pi/Downloads/jace/src/main/java/jace/core/Computer.java:[27,29] package javafx.beans.property does not exist
[ERROR] /home/pi/Downloads/jace/src/main/java/jace/core/Computer.java:[28,29] package javafx.beans.property does not exist

I do not have a machine with JDK 8.

What is the recommended build environment for JACE (JDK version, maven version, host OS version)?

badvision commented 3 years ago

Recommended you build with any OS with either Oracle JDK8 or Open JDK8 + Open Jfx 8 in the lib of the jdk/jre as well. I'm working on a more modern update with OpenJdk11 but am trying to get some bug fixes for an upcoming game release (Lawless Legends) so it will be a little while.

-Brendan

-Brendan

On Sat, Nov 6, 2021, 8:54 PM Eric Scharff @.***> wrote:

JavaFX appears to have been removed from OpenJDK 11 which means jace doesn't build, with errors such as

[ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /home/pi/Downloads/jace/src/main/java/jace/core/Computer.java:[27,29] package javafx.beans.property does not exist [ERROR] /home/pi/Downloads/jace/src/main/java/jace/core/Computer.java:[28,29] package javafx.beans.property does not exist

I do not have a machine with JDK 8.

What is the recommended build environment for JACE (JDK version, maven version, host OS version)?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/badvision/jace/issues/40, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHH5BUMEDQ5KRWFABVZNIDUKXS5HANCNFSM5HQHZNZQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

cybershrapnel commented 10 months ago

here: I tried this it works

Starting from Java 11, JavaFX was decoupled from the standard JDK and is now a standalone module. To use JavaFX in applications with Java 11 or newer, you need to explicitly include JavaFX as a dependency. This can be a bit tricky if you have an older application or jar files that were built expecting JavaFX to be part of the JDK.

Here are the steps you can follow to run your JavaFX application with newer versions of Java:

  1. Download JavaFX SDK First, download the JavaFX SDK for your platform from Gluon's JavaFX downloads page. Ensure you choose the version compatible with your Java version.

  2. Set Up the Classpath You need to include the JavaFX libraries in your classpath. If you're running your application from the command line, use the --module-path option to specify the path to the JavaFX lib directory, and the --add-modules option to specify the JavaFX modules you require.

Assuming you have extracted the JavaFX SDK to a directory (e.g., path/to/javafx-sdk), the command to run your application would look something like this:

bash Copy code java --module-path /path/to/javafx-sdk/lib --add-modules javafx.controls,javafx.fxml -jar your-application.jar Replace /path/to/javafx-sdk/lib with the actual path to the lib directory of the downloaded JavaFX SDK, and your-application.jar with the path to your JavaFX application's JAR file.

The --add-modules option should include all the JavaFX modules your application needs, such as javafx.controls, javafx.fxml, javafx.graphics, etc.

  1. Use a Build Tool If you are using a build tool like Maven or Gradle, you can manage JavaFX dependencies more easily. You can add dependencies for the JavaFX modules you need in your pom.xml (for Maven) or build.gradle (for Gradle) file.

Example for Maven:

xml Copy code

org.openjfx javafx-controls 15 org.openjfx javafx-fxml 15

Adjust the version to match the JavaFX version compatible with your Java version.

  1. IDE Configuration If you are using an IDE like IntelliJ IDEA or Eclipse, you will need to configure your project settings to include the JavaFX library. This often involves adding the JavaFX SDK as a library in your project settings and configuring your run/debug configurations to include the necessary --module-path and --add-modules options.

  2. Use jlink to Create a Custom Runtime Image For production, you might consider using jlink to create a custom runtime image that includes your application and its dependencies, including JavaFX. This way, you can distribute your application without requiring users to set up JavaFX separately.

These steps should allow you to run your older JavaFX application with a newer version of Java. It's important to test your application thoroughly after making these changes, as there could be compatibility issues between different Java and JavaFX versions.

badvision commented 4 months ago

I have overhauled this to build with Java 17 and Java 22. It is recommended to use the Gluon version of GraalVM if you wish to build a native version. See the updated readme for more information.