OpenJDK8和JavaFX在MacOS上

huangapple go评论76阅读模式
英文:

OpenJDK8 and JavaFX on MacOS

问题

我想在 macOS 上运行一个仅适用于 OpenJDK 8 的 JavaFX 应用程序:

  • 我在互联网上搜索,只找到适用于 Linux(使用 apt-get)的解决方案,
  • 我无法升级到 OpenJDK > 8,也不能切换到 Oracle 发行版(上下文限制)。

编辑
问题在于,如果我使用 Oracle JDK 8 运行应用程序,它可以正常工作。但是,如果我使用 OpenJDK 8 运行它,包含 JavaFX 时就会出现问题。例如:

FilterEditor.java:6: 错误找不到 javafx.scene.inputimport javafx.scene.input.KeyEvent;

我正在使用 Gradle 脚本

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) }
  }
}

但如果我使用 OpenJDK 8,就会失败。

英文:

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.

答案1

得分: 1

有几家提供OpenJDK + JavaFX的供应商。例如,您可以从Azul下载:https://www.azul.com/downloads/zulu-community/?version=java-8-lts&os=macos&architecture=x86-64-bit&package=jdk-fx

不过,您应该尝试升级到更近版本的Java/FX。

英文:

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.

huangapple
  • 本文由 发表于 2020年9月11日 15:52:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/63842928.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定