无法解析IntelliJ Idea IDE中的符号javafx.application

时间:2021-10-07 17:01:52

I tried to create a JavaFX application in IntelliJ Idea IDE but I got compile error that said:

我尝试在IntelliJ Idea IDE中创建一个JavaFX应用程序,但是我遇到了编译错误:

java: package javafx.application does not exist.

java:包javafx.application不存在。

I have changed the Project SDK and the Project Language Level to Java 8, reloaded the project but it didn't help. Then I checked if JavaFX plugin was enabled in the settings.

我已将Project SDK和Project Language Level更改为Java 8,重新加载项目但它没有帮助。然后我检查了设置中是否启用了JavaFX插件。

The search on Google and * didn't give me more ideas of what is wrong. Thank for any help in advance.

对Google和*的搜索没有给我更多关于错误的想法。提前感谢您的帮助。

P.S. I am using IntelliJ Idea 14.0 with java8.1.0_25 on archlinux OS.

附:我在archlinux OS上使用IntelliJ Idea 14.0和java8.1.0_25。

5 个解决方案

#1


51  

As indicated here, JavaFX is no longer included in openjdk.

如此处所示,openfdk中不再包含JavaFX。

So check, if you have <Java SDK root>/jre/lib/ext/jfxrt.jar on your classpath under Project Structure -> SDKs -> 1.x -> Classpath? If not, that could be why. Try adding it and see if that fixes your issue, e.g. on Ubuntu, install then openjfx package with sudo apt-get install openjfx.

如果您在项目结构 - > SDKs - > 1.x - > Classpath下的类路径上有 /jre/lib/ext/jfxrt.jar,请检查一下。如果没有,那可能就是原因。尝试添加它,看看是否能解决您的问题,例如:在Ubuntu上,使用sudo apt-get install openjfx安装openjfx包。

#2


10  

You need to download the java-openjfx package from the official Arch Linux repos. (Also, make sure you have the openjdk8-openjdk package). After doing that, open your project in Intellij and go to Project-Structure -> SDKs -> 1.8 -> Classpath and try removing the old JDK you had and clicking on the directory for the new JDK that will now contain jfxrt.jar.

您需要从官方的Arch Linux repos下载java-openjfx包。 (另外,请确保您有openjdk8-openjdk包)。完成后,在Intellij中打开项目并转到Project-Structure - > SDKs - > 1.8 - > Classpath并尝试删除旧的JDK,然后单击现在将包含jfxrt.jar的新JDK的目录。

#3


8  

This should be your perfect solution. Try and enjoy. If some command not work properly that means if you get any error. Try to solve it yourself. I have given you main thing that you need. if your application in different location, Or your system architecture is different. solve it yourself. Very easy to do this. Just follow my given solution.

这应该是您完美的解决方案。尝试并享受。如果某些命令无法正常工作,则表示您收到任何错误。尽量自己解决。我给你了你需要的主要东西。如果您的应用程序位于不同的位置,或者您的系统架构不同。自己解决。很容易做到这一点。按照我给出的解决方案。

Step 0:

sudo apt-get install openjdk-8-jre

Step: 1

sudo apt-get install openjfx

Step 2:

sudo cp /usr/share/java/openjfx/jre/lib/ext/* /usr/lib/jvm/java-1.8.0-openjdk-amd64/lib

Step 3:

sudo cp /usr/share/java/openjfx/lib/* /usr/lib/jvm/java-1.8.0-openjdk-amd64/lib

Step 4:

sudo chmod 777 -R /usr/lib/jvm/java-1.8.0-openjdk-amd64

now open a new project or rebuild your project. Good luck.

现在打开一个新项目或重建您的项目。祝你好运。

#4


7  

You can use the one that comes with IntelliJ: <intellij>/jre64/lib/ext/jfxrt.jar.

您可以使用IntelliJ附带的那个: /jre64/lib/ext/jfxrt.jar。

#5


1  

You might have a lower project language level than your JDK.

项目语言级别可能低于JDK。

Check if: "Projeckt structure/project/Project-> language level" is lower than your JDK. I had the same problem with JDK 9 and the language level was per default set to 6.

检查:“Projeckt结构/项目/项目 - >语言级别”是否低于JDK。我遇到了与JDK 9相同的问题,语言级别默认设置为6。

I set the Project Language Level to 9 and everything worked fine after that.

我将Project Language Level设置为9,之后一切正常。

You might have the same issue.

您可能遇到同样的问题。

#1


51  

As indicated here, JavaFX is no longer included in openjdk.

如此处所示,openfdk中不再包含JavaFX。

So check, if you have <Java SDK root>/jre/lib/ext/jfxrt.jar on your classpath under Project Structure -> SDKs -> 1.x -> Classpath? If not, that could be why. Try adding it and see if that fixes your issue, e.g. on Ubuntu, install then openjfx package with sudo apt-get install openjfx.

如果您在项目结构 - > SDKs - > 1.x - > Classpath下的类路径上有 /jre/lib/ext/jfxrt.jar,请检查一下。如果没有,那可能就是原因。尝试添加它,看看是否能解决您的问题,例如:在Ubuntu上,使用sudo apt-get install openjfx安装openjfx包。

#2


10  

You need to download the java-openjfx package from the official Arch Linux repos. (Also, make sure you have the openjdk8-openjdk package). After doing that, open your project in Intellij and go to Project-Structure -> SDKs -> 1.8 -> Classpath and try removing the old JDK you had and clicking on the directory for the new JDK that will now contain jfxrt.jar.

您需要从官方的Arch Linux repos下载java-openjfx包。 (另外,请确保您有openjdk8-openjdk包)。完成后,在Intellij中打开项目并转到Project-Structure - > SDKs - > 1.8 - > Classpath并尝试删除旧的JDK,然后单击现在将包含jfxrt.jar的新JDK的目录。

#3


8  

This should be your perfect solution. Try and enjoy. If some command not work properly that means if you get any error. Try to solve it yourself. I have given you main thing that you need. if your application in different location, Or your system architecture is different. solve it yourself. Very easy to do this. Just follow my given solution.

这应该是您完美的解决方案。尝试并享受。如果某些命令无法正常工作,则表示您收到任何错误。尽量自己解决。我给你了你需要的主要东西。如果您的应用程序位于不同的位置,或者您的系统架构不同。自己解决。很容易做到这一点。按照我给出的解决方案。

Step 0:

sudo apt-get install openjdk-8-jre

Step: 1

sudo apt-get install openjfx

Step 2:

sudo cp /usr/share/java/openjfx/jre/lib/ext/* /usr/lib/jvm/java-1.8.0-openjdk-amd64/lib

Step 3:

sudo cp /usr/share/java/openjfx/lib/* /usr/lib/jvm/java-1.8.0-openjdk-amd64/lib

Step 4:

sudo chmod 777 -R /usr/lib/jvm/java-1.8.0-openjdk-amd64

now open a new project or rebuild your project. Good luck.

现在打开一个新项目或重建您的项目。祝你好运。

#4


7  

You can use the one that comes with IntelliJ: <intellij>/jre64/lib/ext/jfxrt.jar.

您可以使用IntelliJ附带的那个: /jre64/lib/ext/jfxrt.jar。

#5


1  

You might have a lower project language level than your JDK.

项目语言级别可能低于JDK。

Check if: "Projeckt structure/project/Project-> language level" is lower than your JDK. I had the same problem with JDK 9 and the language level was per default set to 6.

检查:“Projeckt结构/项目/项目 - >语言级别”是否低于JDK。我遇到了与JDK 9相同的问题,语言级别默认设置为6。

I set the Project Language Level to 9 and everything worked fine after that.

我将Project Language Level设置为9,之后一切正常。

You might have the same issue.

您可能遇到同样的问题。