user3226170
user3226170

Reputation: 175

Cannot get JavaFX to work in Eclipse

I'm trying to use JavaFX in Eclipse but whenever I use any of it's Classes it doesn't recognize the type. To clarify I get the message "Dropshadow cannot be resolved to a type"

This happens not only with Dropshadow, but with any of the JavaFX classes. The IDE won't give me an option to import it and when I try and to type it in manually it isn't recognized. In using JSE 8u25, which apparently has it included.

In looking around I see that the .jar file can be added manually, but I would like to know if something within my IDE isn't configured right, because it should be working. Can anybody give me a hand with this? Thanks.

Upvotes: 2

Views: 26318

Answers (4)

Deepika Sachdeva
Deepika Sachdeva

Reputation: 111

Step1 Download JavaFX zip folder and place it into save folder like document folder

https://gluonhq.com/products/javafx/ Step 2 File -> New Project -> Java Project

Step3 Right on Project Click on properties -> Click on Libraries Add Library --> Add New --> Add External Jars

Step4 - Remove module-info.java file from your project

Step5 - Set the VM Arguments Click on Run--> Run Configuration --> Arguments

Add Path Like this (my sdk present in documents folder)

--module-path /Users/MICROSOFT/Documents/javafx-sdk-17.0.6/lib --add-modules javafx.controls,javafx.fxml

Thanks

Upvotes: 0

Cristian Babarusi
Cristian Babarusi

Reputation: 1505

The simple way to solve your issue is to right click your project, go to properties > java build path then select the tab where it says Libraries. You have to select that library you have in there > click the button EDIT then select from there Workspace default JRE . You need to have at least java 8.

Upvotes: 1

user3226170
user3226170

Reputation: 175

So I finally got it working, the solution was to install the eclipse plugin found here:

http://www.eclipse.org/efxclipse/install.html

The directions are pretty good, I just followed them as written and got it up and running.

Upvotes: 2

user4441304
user4441304

Reputation:

Adding to Build Path

Your problem here, is that you just dropped your .jar file right in there, and tried using it. You need to add it to the project. To do so, follow the below steps:

  1. Add the .jar file to your project folder (not src) via. copy/paste or simply drag/drop.
  2. Right click on the .jar file once it's inside your project.
  3. Press Build Path > Add To Build Path

What you have/will done, is adding the .jar to the project itself. Theres a difference between having it in your project, and having it a part of your project.

Now you can import, extend, implement, whatever you need.


Removing from Build Path

Ok, so you found a better library for what you want, no longer need the library or made your own, and you want to delete your .jar.

Well, firstly, it's still a part of your project, so you need to remove it from the Build Path first.

  1. Right click on the .jar file.
  2. Press Build Path > Remove from Build Path

Your .jar is still inside your project, but no longer a part of it.

Now you may go ahead and delete it without worry.

Upvotes: 1

Related Questions