1
votes

I looked on many similar questions but the solutions didnt help me :(

This is my openjfx lib

This is the jfx doc

I can import the lib in 2 ways:

1. In the java build path I can use this way all the classes without problems... BUT i cant load the java doc or source, if i do, it does not work.

or...

2. edit the installed JRE definitions This way I add like explained in other Questions the jfxrt.jar in the installed jre and i give it the source and doc. AND it WORKS! ... nearly... The documentation works now... but not all imports. :(

import javafx.application.Platform;       //this works
import javafx.scene.control.ListView;     //this works
import javafx.scene.control.ProgressBar;  //this works
import javafx.scene.control.TextField;    //this works
import javafx.scene.layout.Background;    //this DOES NOT work :(
import javafx.scene.layout.BackgroundFill;//this DOES NOT work :(
import javafx.scene.layout.Border;        //this DOES NOT work :(
import javafx.scene.layout.BorderPane;    //this works again ._.

The error i get is: "The import javafx.scene.layout.Background cannot be resolved"

Well... when doing the 1st step (from This is my openjfx lib). I have absolutly no import issues and i can work perfectly, but the doc doesnt work.

And now with 2. edit the installed JRE definitions the doc does work but i have import issues with certain stuff and i dont understand why :(

Obviously I am doing something wrong... (i am pretty new to java)

my java -version:

java version "13" 2019-09-17
Java(TM) SE Runtime Environment (build 13+33)
Java HotSpot(TM) 64-Bit Server VM (build 13+33, mixed mode, sharing)

(i had some bug earlier using the fx and it got fixed by updating my eclipse 2019-09)

Well. i hope you can help me ^^

1
I also tryed e(fx)clipse and added the fx-sdk in the buildpath but could not resolve every importnninja
Where did you get a jfxrt.jar for JavaFX 11+?? That doesn't exist anymore. If it is from an older version (10 or less), that might explain some import issues. But this is not the way to do it. See openjfx.io/openjfx-docs/#IDE-EclipseJosé Pereda

1 Answers

6
votes

To run JavaFX 11+ on Eclipse, you have to follow the documentation here: https://openjfx.io/openjfx-docs/#IDE-Eclipse.

If you are not using Maven/Gradle build tools:

  • Download the JavaFX 13 SDK from here
  • Create a JavaFX13 library with the JavaFX jars.
  • Add the VM arguments to your run configuration.

JavaDoc and Sources

To get javadoc and sources working, you shouldn't add a (very old) jfxrt.jar, that is from and old JavaFX version, so you will get mismatches because some changes in packages.

The proper way to do it, if you already have your JavaFX13 library is:

  • Edit the library (Eclipse -> Preferences -> Java -> Build Path -> User Libraries -> JavaFX13), and display all the jars included. If you display the content of any of these jars, you will probably see:

    Source attachment: (None)
    Javadoc location: (None)
    
    • Jar by jar, select Source attachment, press the Edit... button, select External location, and find the src.zip file under the lib folder of your local JavaFX SDK.

Source and Javadoc

  • Jar by jar, select Javadoc location, press the Edit... button, select Javadoc URL, and paste https://openjfx.io/javadoc/13/.

  • Apply and close, when done.

You should now get Javadoc when hovering any JavaFX class, and also access to source code when Ctrl+Click a JavaFX class.