14

JavaFX is supposed to be included with the latest release of the JDK. I'm using 1.7 v 17. Imports like:

import javafx.fxml.Initializable;

are not recognized. I would prefer not to have to link to the jar manually.

I heard that this was a bug before, but that it should have been fixed. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7166330

Does anyone have an answer on how javafx can be recognized. I don't want to have e(fx)clipe do it for me and I don't want to have to link the jar. As far as I understand, it;s now included in the latest release of the jdk, therefor I should be able to do an import like above right?

Matt
  • 5,408
  • 14
  • 52
  • 79

4 Answers4

13

JavaFX isn't on any of the default classpaths in JDK7 - please see in which version the bug has been fixed!

In JDK8 this is fixed and JavaFX is on the ExtensionClasspath but still you'll get warnings from Eclipse because stuff on the extension classpath is considered an implementation detail - you'll can fix this yourself in the JRE-Runtimes.

What's your problem with e(fx)clipse? It would fix all your problems no matter if you develop against JDK7 or JDK8?

tomsontom
  • 5,856
  • 2
  • 23
  • 21
  • 1
    Thanks Tom. I actually _do_ have your e(fx)clipse installed, but it hasn't fixed the imports, and any @FXML is not recognized. I realized this because I followed your link here http://efxclipse.org/install.html#for-the-ambitious and it told me it was already installed. I had mentioned that I wouldn't like to use anything else simply because I thought it should be working without doing anything "special" by now. – Matt Mar 23 '13 at 22:55
  • So did you get e(fx)clipse running now? If you have problems running it we should try to track down what is not working in your case. One reason could be that your eclipse is not started with JDK7 hence e(fx)clipse will not load. You also have to create projects using the the wizard or manually add the JavaFX classpath container using the projects properties dialog – tomsontom Mar 23 '13 at 23:04
  • It must be running since I can use the css hinting features... My controller class still doesn't recognize any javafx imports as noted above... Should I re-create the project using the wizard to see if that helps? – Matt Mar 24 '13 at 00:10
  • I also keep getting this "Do you want to add the Xtext nature to the project .." on every startup. – Matt Mar 24 '13 at 00:16
  • this is because the CSS-Editor is based on Xtext - Like I said, simply add the JavaFX-Classpath-Container to projects you want to use JavaFX in. – tomsontom Mar 24 '13 at 01:36
13

On Ubuntu 14.10 I had to install first openjfx

sudo apt-get install openjfx

then I created a default project using e(fx)clipse and the default JRE (java-8-openjdk-amd64).

ZiglioUK
  • 2,573
  • 4
  • 27
  • 32
6

You can add the "jfxrt.jar" manually! Its in the installed JDK. Example:

  • Windows XP: "C: \ Program Files \ Java \ jdk1.7.0_17 \ jre \ lib \ jfxrt.jar"
  • Windows 7 (32 bit): "C: \ Program Files (x86) \ Java \ jdk1.7.0_17 \ jre \ lib \ jfxrt.jar"
  • Windows 7 (64 bit): "C: \ Program Files \ Java \ jdk1.7.0_17 \ jre \ lib \ jfxrt.jar"

Copy the jar file and put it to a subfolder in the project (for example, / lib).

Now add the "jfxrt.jar" to the classpath. Click the right mouse button on the project and select from Properties -> Java Build Path -> Libraries -> Add JARs from ... and add the jar file.

skiphoppy
  • 97,646
  • 72
  • 174
  • 218
AxxG
  • 206
  • 3
  • 11
  • Thanks too. I've solved my problem using your answer, and this other SO answer : https://stackoverflow.com/questions/15278215/maven-project-with-javafx-with-jar-file-in-lib , by setting the path to the java FX jar in the Maven depencies. – Anthony BONNIER Aug 28 '18 at 13:35
0

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

Step2 - 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