Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenJDK8 and JavaFX on MacOS

I would like to run a JavaFX application on macOS that has only OpenJDK8:

  • I searched on the internet and I only found solutions for Linux (with apt-get),
  • I cannot upgrade to OpenJDK>8 and I cannot switch to Oracle distributions (context constraints).

** Edit ** The problem is that if I run the application with OracleSDK8 it works perfectly fine. But if I run it with OpenJDK8 I have problems when including JavaFX. For example:

FilterEditor.java:6: error: package javafx.scene.input does not exist
import javafx.scene.input.KeyEvent;

I'm using a Gradle script

jar {
     if(JavaVersion.current() >= JavaVersion.VERSION_11){
       apply plugin: 'org.openjfx.javafxplugin'
       javafx {
        version = "11"
        modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.swing' ]
      }
      }else if(JavaVersion.current() != JavaVersion.VERSION_1_8){
        throw new GradleException("This build script must be run with java 8 or a java version >= 11")
      }
  destinationDir = projectDir
  manifest.attributes 'Main-Class': project.mainClassName
  baseName = 'XXX'
  from {
    configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
  }
}

But if fails if I use OpenJDK8.

like image 634
Idriss Riouak Avatar asked Nov 24 '25 18:11

Idriss Riouak


1 Answers

There are several providers of OpenJDK + JavaFX. E.g. you can download that from Azul: https://www.azul.com/downloads/zulu-community/?version=java-8-lts&os=macos&architecture=x86-64-bit&package=jdk-fx

Nevertheless you should try to upgrade to a more recent version of Java/FX.

like image 107
mipa Avatar answered Nov 26 '25 07:11

mipa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!