Java does not import the JavaFX library
After automatically creating the JavaFX application project in Intellij IDEA, the Java compiler outputs the following message at startup:
`/home/greenmiler/IdeaProjects/untitled/src/main/java/sample/Main.java
Error:(1, 26) java: package javafx.application does not exist
Error:(2, 19) java: package javafx.fxml does not exist
Error:(3, 20) java: package javafx.scene does not exist
Error:(4, 20) java: package javafx.scene does not exist
Error:(5, 20) java: package javafx.stage does not exist
Error:(7, 27) java: cannot find symbol
symbol: class Application
Error:(10, 23) java: cannot find symbol
symbol: class Stage
location: class Main
Error:(9, 5) java: method does not override or implement a method from a supertype
Error:(11, 9) java: cannot find symbol
symbol: class Parent
location: class Main
Error:(11, 39) java: cannot find symbol
symbol: method getClass()
location: class Main
Error:(11, 23) java: cannot find symbol
symbol: variable FXMLLoader
location: class Main
Error:(13, 35) java: cannot find symbol
symbol: class Scene
location: class Main
Error:(19, 9) java: cannot find symbol
symbol: method launch(java.lang.String[])
location: class Main`
As I understand it, Java may not import JavaFX, but why? The system has Oracle JDK 11 installed, which should include the JavaFX library, or am I wrong? I also tried to run the openjdk-11-jdk package on JDK c and the JavaFX command apt install openjfx-*
installed, but the output did not change.
What am I doing wrong?
2
Author: GreenMiler, 2018-11-08
2 answers
Starting from versions after 8, JavaFX is allocated to a separate OpenJFX project, respectively, it is no longer supplied with the JDK. At one time, to run a project on JavaFX and OpenJDK 11, I drew information from hence
4
Author: zolt, 2018-11-09 02:26:09
- You're wrong. JavaFX is not included in Oracle JDK 11, it must be installed separately. If you want to have JavaFX included, install Oracle JDK 8.
- After installing the new JDK in the system, if you did not delete the previously installed previous version, you need to configure which of the previously installed JDKs will be used by the system by default. Run the command
sudo update-alternatives --config java
, select from the installed JDK/JVM the one you want to assign by default, check the settingsjava -version
See here Choosing the default Java to use with pictures.
2
Author: Igor Kudryashov, 2018-11-09 09:42:45