I have a new pc, I have installed inteliJ with JDK and JRE 9.0.1. I also installed SceneBuilder 9.0.1. I have copied the project that I had on old pc and when I run it I get this error: Error:(3, 26) java: package javafx.application does not exist. Do I need to install something else that contains this package? Thank you.
-
What OS? Where did you install JRE from? – Itai Nov 09 '17 at 15:07
-
do you use a module? if yes, you probably do not declare addiction to the package. – mr mcwolf Nov 09 '17 at 20:12
-
Win 10, JRE from Oracle. – LauCirco Nov 09 '17 at 21:00
-
1"do you use a module? if yes, you probably do not declare addiction to the package" -- I dont know what to say here – LauCirco Nov 09 '17 at 21:00
-
1Does this answer your question? [IntelliJ can't recognize JavaFX 11 with OpenJDK 11](https://stackoverflow.com/questions/52467561/intellij-cant-recognize-javafx-11-with-openjdk-11) – Davide Jan 08 '20 at 10:36
8 Answers
The JavaFX package is not included in JDK 9 and later. You need to install JDK 8, or you can add the JavaFX package separately, for example, from JDK 8 (jfxrt.jar
).

- 5,100
- 13
- 43
- 62

- 307
- 2
- 4
-
This makes sense as to why the tutorial I am watching works flawlessly. Thanks – Angus Jan 07 '20 at 08:49
-
1I don’t know why this has so many upvotes. JavaFX has both native and Java components. `jfxrt.jar` only has the Java components, not the native components and the Java components are only compatible with the native components for that version. Simply copying `jfxrt.jar` and trying to use it with another distribution is a bad idea. Also Java 8 is now obsolete. To use JavaFX with a recent Java version either use a Java distribution which includes JavaFX like Liberica, or follow the instructions for using JavaFX modules documented at openjfx.io. – jewelsea Oct 22 '21 at 10:50
Try this solution in IDEA press ctrl+shift+alt+s
(File -> Project Structure) then select Project -> Project Language Level
and select 8 or above.

- 1
- 1

- 149
- 3
If this happens to you in a modular project with JavaFx version 17 using Maven, just try the usual things like standing on your head, walking on the ceiling, rotating the Earth in the opposite direction or even reading https://openjfx.io/openjfx-docs/ and then just switch to the version 17.0.1 or later and it should work:
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17.0.1</version>
</dependency>

- 1,260
- 1
- 14
- 26
Be careful. This solution only tested on Linux (Ubuntu 16.04 & Debian 8) And for Java 1.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.

- 666
- 5
- 14
-
7They have said they use Windows - this is all for Linux (specifically Debian/Ubuntu), so it is irrelevant. – Itai Dec 27 '17 at 10:18
-
9It might be irrelevant for the OP, but it is relevant for the title. I came here for the title, and this answer solved my problem. – mazunki Apr 29 '20 at 23:07
-
1
If you are java 8+ the javafx libs are not included. you need to add them via your favorite build tool as a compile runtime lib.

- 135
- 6
Step 1: Configuring everything to java 9
First you need to make sure everything is configured to java 9. Click on File->Project Structure
On the project menu you have the Project SDK and the language level (Image)
And on the modules menu you have to check 2 tabs (you probably have to to it for every module):
Step 2 Rebuilding your project
Then you need to rebuild your project:
Right-click on your project and click on Rebuild Module (Image)
Then just wait until your project is rebuilt and try to run it again.
-
I added somethings you might need to do before rebuilding the project. – Fernando Magalhaes fbeneditovm Nov 30 '17 at 19:47
My problem was that I deleted my SDK 15 and installed SDK 16. Check your Libraries locations under File -> Project Structure -> Libraries. If your library version is lower than what you have selected under Project Settings -> Project -> Project SDK. You are going to have a bad time.
I've reproduced the same issue after adding the library, but using Java 11
& JavaFX 11
.
To fix it, I've followed such steps:
- Firstly, click
Project Structure
->Libraries
and check if library isn't used:
- Secondly, open
Project Structure
->Problems
and click[Fix]
->Add to Dependencies...
:
- Thirdly, choose as
module
and clickOK
:
- Lastly, click
Apply
andOK
.
As result, will be:

- 5,872
- 9
- 36
- 76