简体   繁体   English

无法在 MacOS 上的 Eclipse 上安装 JavaFX

[英]Unable to Install JavaFX on Eclipse on MacOS

I am unable to install JavaFX on Eclipse.我无法在 Eclipse 上安装 JavaFX。 I get this error message when attempting to run HelloFX:尝试运行 HelloFX 时收到此错误消息:

Error: Could not find or load main class javafx.fxml Caused by: java.lang.ClassNotFoundException: javafx.fxml错误:无法找到或加载主 class javafx.fxml 原因:java.lang.ClassNotFoundException: ZD4365F2682EFB002465F2682EFB0002465F2682EFB000824DDD.

I have a Mac Pro 5,1 running MacOS 10.14.6 Mojave.我有一台运行 MacOS 10.14.6 Mojave 的 Mac Pro 5,1。 It is heavily upgraded, and I do not believe that this is the issue, although it is a 2012 machine.它进行了大量升级,我不认为这是问题所在,尽管它是 2012 年的机器。

I have tried earlier and later versions of JDK, JFX and Eclipse.我尝试过JDK、JFX和Eclipse的早期和更新版本。 Either with no change or worse results.要么没有变化,要么结果更糟。 AdoptOpenJDK version 8.0 produced additional errors. AdoptOpenJDK 8.0 版产生了额外的错误。 Currently I have installed:目前我已经安装:

AdoptOpenJDK 16 and AdoptOpenJDK-11.0.11+9 were both tried, and placed in the usual directory: /Library/Java/JavaVirtualMachines/jdk-16.jdk/ AdoptOpenJDK 16 和 AdoptOpenJDK-11.0.11+9 都试过了,放在通常的目录下:/Library/Java/JavaVirtualMachines/jdk-16.jdk/

This line was added to.bash_profile export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-16.jdk/Contents/Home此行已添加到 .bash_profile export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-16.jdk/Contents/Home

javafx-sdk-11.0.2 was placed in: /Library/Java/Extensions/javafx-sdk-11.0.2/lib And the following line added to.bash_profile: export PATH_TO_FX=Library/Java/Extensions/javafx-sdk-11.0.2/lib javafx-sdk-11.0.2 被放置在:/Library/Java/Extensions/javafx-sdk-11.0.2/lib 并在.bash_profile中添加以下行:export PATH_TO_FX=Library/Java/Extensions/javafx-sdk-11.0 .2/lib

Eclipse Version: 2021-03 (4.19.0) was installed using the installer app. Eclipse 版本:2021-03 (4.19.0) 是使用安装程序安装的。 version 1.20.0, after clearing out the 'hidden' config files from earlier versions.版本 1.20.0,从早期版本中清除“隐藏”配置文件后。

/Users/baron/JWS was configured as the Java Work Space. /Users/baron/JWS 被配置为 Java 工作空间。 All old java project, packets and other files were removed to a backup location before installation of Eclipse.在安装 Eclipse 之前,所有旧的 java 项目、数据包和其他文件都已删除到备份位置。 A project was built using the HelloFX files from openjfx "Getting Started with JavaFX".使用 openjfx“JavaFX 入门”中的 HelloFX 文件构建了一个项目。

~/JWS/HelloJFX/src/HelloFX/Controller.java ~/JWS/HelloJFX/src/HelloFX/Controller.java

~/JWS/HelloJFX/src/HelloFX/Hellofx.fxml ~/JWS/HelloJFX/src/HelloFX/Hellofx.fxml

~/JWS/HelloJFX/src/HelloFX/Main.java ~/JWS/HelloJFX/src/HelloFX/Main.java

A user library was created from the jar files: Preferences/Java/Build Path/User Libraries/JavaFX11用户库是从 jar 文件创建的:Preferences/Java/Build Path/User Libraries/JavaFX11

The User Library contained all the expected components.用户库包含所有预期的组件。 The User Library JavaFX11 was attached to the project, and appeared as expected.用户库 JavaFX11 已附加到项目中,并按预期出现。

Main args were added as follows: --module-path /path/to/javafx-sdk-15.0.1/lib --add-modules javafx.controls,javafx.fxml主要参数添加如下: --module-path /path/to/javafx-sdk-15.0.1/lib --add-modules javafx.controls,javafx.fxml

This was copy pasted from the openjfx.io site, so there is no typing error here.这是从 openjfx.io 站点复制粘贴的,所以这里没有输入错误。 Indeed, I followed exactly the instruction on this site.事实上,我完全按照这个网站上的说明进行操作。

Incidentally, it was not possible to run any java from the command line if it contained javafx imports (but that is a separate problem).顺便说一句,如果 java 包含 javafx 导入,则无法从命令行运行任何 java(但这是一个单独的问题)。

I have lost days on this already.我已经为此失去了几天。 The answers to others with the similar difficulties have not helped in my case.其他有类似困难的人的答案对我没有帮助。 Expert help very welcome.非常欢迎高手帮忙。

JDK with JavaFX bundled JDK 与 JavaFX 捆绑

One option is to install a Java implementation on your Mac that comes bundled with the OpenJFX ( JavaFX ) libraries.一种选择是在与OpenJFX ( JavaFX ) 库捆绑在一起的 Mac 上安装 Java 实现。

At least two vendors provide such a JDK :至少有两家供应商提供这样的JDK

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM