问题
I have the latest JDK (update 65), but Eclipse doesn't even recognize JavaFX when I try to import it.
How do I fix this and import it?
回答1:
After following these steps
- Go Help
- Go Eclipse MarketPlace
- Search e(fx)clipse
- Install it
you can import javafx and if you want to add on your project just follow:
Java Build Path
-> Libraries
-> Add Libraries
-> JavaFx SDK
回答2:
Follow the steps:
Go Help
Go Eclipse MarketPlace...
Search e(fx)clipse
Install It
回答3:
Do these following steps:
- Open Eclipse -> Help -> Eclipse Marketplace
- Search for "javafx"
- You'll see e(fx)eclipse, install it.
- After installation, restart eclipse
- Then create new project File > New > Project(don't select Java project).
- Then Select JavaFX > JavaFX Project
- Then click Next, give project name and click Finish
- You'll get "The import javafx cannot be resolved"
- Download JavaFX in here JavaFX
- Extract the folder and place it downloads folder (or anyplace)
- Then in eclipse right click the project and select properties
- Choose Java Build Path
- Then select Libraries tab (you'll see tabs on the top)
- You'll see Classpath > JavaFX SDK
- Click on Classpath, then click Add external JARs from the right.
- Then from the download JavaFX (placed in downloads folder or somewhere you've placed).
- Choose all the .jars file in Downloads/javafx-sdk-11.0.2/lib/(all .jar(s) file) and click open.
- Then click Apply and Apply and close.
- Then you won't get red underlines or (error).
- Then right click on project > Run as > Run configuration
- Choose the arguments tab and type this in VM arguments.
--module-path /path/to/JavaFX/lib --add-modules=javafx.controls,javafx.fxml
- (Important) Then uncheck the box that says "Use the -XstartOnFirstThread..."
- Click Apply and Run.
来源:https://stackoverflow.com/questions/33819052/how-do-i-import-javafx-into-eclipse