问题
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.
回答1:
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
).
回答2:
Try this solution in IDEA press ctrl+shift+alt+s
(File -> Project Structure) then select Project -> Project Language Level
and select 8 or above.
回答3:
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.
回答4:
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.
回答5:
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):
Souces has got the language level (Image)
And dependences has got the Module SDK (Image)
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.
来源:https://stackoverflow.com/questions/47198457/error3-26-java-package-javafx-application-does-not-exist