File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JavaFX and the fly likes The import javafx cannot be resolved Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JavaFX
Bookmark "The import javafx cannot be resolved" Watch "The import javafx cannot be resolved" New topic
Author

The import javafx cannot be resolved

Shikha Upadhyaya
Ranch Hand

Joined: Aug 17, 2011
Posts: 70

Hi,

I am trying to develop any application using JavaFX. I am using Eclipse Indigo and JavaFX 2.0 SDK. I have installed the JavaFX plugin to eclipse and followed these steps to create a project: Create project using JavaFX.

But when I try this code:


I get the following multiple errors of this kind:
What do I do?
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
The error straight forwardly implies javafx is not present in the project's class path. You should rather try the HelloWorld application provided in the tutorial link you posted.

And follow the steps from scratch to the HelloWorld program.
Shikha Upadhyaya
Ranch Hand

Joined: Aug 17, 2011
Posts: 70

John Jai wrote:The error straight forwardly implies javafx is not present in the project's class path. You should rather try the HelloWorld application provided in the tutorial link you posted.

And follow the steps from scratch to the HelloWorld program.

I have added JavaFX to the project's class path. I tried the HelloWorld program given there too. But the errors persist.

I am going through this thread. There seems to be no satisfactory conclusion there too.
Shikha Upadhyaya
Ranch Hand

Joined: Aug 17, 2011
Posts: 70

Could it be problem with the JavaFX plug-in?
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Class path should point to a location where your class files (or jar files) are present. Is there a lib folder parallel to the bin in the Java FX installation? Does that have jar files?
Shikha Upadhyaya
Ranch Hand

Joined: Aug 17, 2011
Posts: 70

John Jai wrote:Class path should point to a location where your class files (or jar files) are present. Is there a lib folder parallel to the bin in the Java FX installation? Does that have jar files?


There is no lib folder.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

I moved this thread to JavaFX forum.

I dont think Eclipse has a plugin for JavaFX 2.0 yet, but this post would help you to configure your eclipse.

And the link you have mentioned is for older verion of JavaFX.

You can download Netbeans 7.1 beta from here which comes with JavaFX 2 support.

Note that JavaFX 2.0 is not compatible with older versions. So when you are searching use the version number.


Mohamed Sanaulla | My Blog
Shikha Upadhyaya
Ranch Hand

Joined: Aug 17, 2011
Posts: 70

Mohamed Sanaulla wrote:I moved this thread to JavaFX forum.

I dont think Eclipse has a plugin for JavaFX 2.0 yet, but this post would help you to configure your eclipse.

And the link you have mentioned is for older verion of JavaFX.

You can download Netbeans 7.1 beta from here which comes with JavaFX 2 support.

Note that JavaFX 2.0 is not compatible with older versions. So when you are searching use the version number.


Since my entire project is in Eclipse, I would like to stick on to Eclipse. Which (older)version of JavaFX do I have to install? Could you please give me the link?
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

Did you visit the link I provided in my reply for configuring Eclipse?
You should be using JavaFX 2.0 and above version. Older versions are not supported anymore.
Shikha Upadhyaya
Ranch Hand

Joined: Aug 17, 2011
Posts: 70

Mohamed Sanaulla wrote:Did you visit the link I provided in my reply for configuring Eclipse?
You should be using JavaFX 2.0 and above version. Older versions are not supported anymore.

Thank you. I don't get this error now-

But there is this error in the line 11 of the code I posted in the first post of this thread-
What do I do?
Shikha Upadhyaya
Ranch Hand

Joined: Aug 17, 2011
Posts: 70

Shikha Upadhyaya wrote:
But there is this error in the line 11 of the code I posted in the first post of this thread-
What do I do?

I fixed this error.

But now I have a new exception in my program.

How do I set this right?
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

Have you installed the JavaFX SDK? I think its missing the runtime related files. Not sure though. Try installing runtime again.
Shikha Upadhyaya
Ranch Hand

Joined: Aug 17, 2011
Posts: 70

Mohamed Sanaulla wrote:Have you installed the JavaFX SDK?

I have installed JavaFX 2.0 SDK which is now located in C:/Program Files/Oracle. I have also set the class path to C:/Program Files/Oracle/JavaFX2.0 SDK.
Mohamed Sanaulla wrote:I think its missing the runtime related files. Not sure though. Try installing runtime again.

I have installed and uninstalled and again installed JavaFX 2.0 SDK twice. No change in the exception list. Is there something called installing the runtime separately? If yes, how do I do it?

But I would like to stress upon one observation here. When I click on File > New > JavaFX project, a window "New JavaFX project" opens. In that window I can see an error message- A valid JavaFX SDK was not detected.

Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

If you have JavaFX SDK then you have the runtime as well.

Shikha Upadhyaya wrote:

But I would like to stress upon one observation here. When I click on File > New > JavaFX project, a window "New JavaFX project" opens. In that window I can see an error message- A valid JavaFX SDK was not detected.



I dont think Eclipse supports New JavaFX project as I am not sure if Eclipse has a plugin to support JavaFX 2.0. You must be creating a usual Java project and then follow the JavaFX sample code - Am just thinking loud here, not tried it.
But on Netbeans 7.1 beta you can create a new JavaFX project and proceed with the development - I have tried this though.
Shikha Upadhyaya
Ranch Hand

Joined: Aug 17, 2011
Posts: 70

Mohamed Sanaulla wrote:If you have JavaFX SDK then you have the runtime as well.

I dont think Eclipse supports New JavaFX project as I am not sure if Eclipse has a plugin to support JavaFX 2.0. You must be creating a usual Java project and then follow the JavaFX sample code - Am just thinking loud here, not tried it.
But on Netbeans 7.1 beta you can create a new JavaFX project and proceed with the development - I have tried this though.

Oh Shifting the entire project to Netbeans would be tedious. There's nothing at all which can be done. Any other breakthrough using Eclipse only as the IDE?
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

You can try creating a usual Java project and then add the javafxrt jar as mentioned here and then try to create the sample application. Also uninstall the javaFX plugin which you have installed for Eclipse.
Shikha Upadhyaya
Ranch Hand

Joined: Aug 17, 2011
Posts: 70

Mohamed Sanaulla wrote:You can try creating a usual Java project and then add the javafxrt jar as mentioned here and then try to create the sample application. Also uninstall the javaFX plugin which you have installed for Eclipse.

I just tried this piece of code. The same set of exceptions continue to show up.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

I used Eclipse Helios to run JavaFX application and it works. I didnt install any JavaFX plugin for Eclipse.
Also I created a simple Java project and then added the following:


I also added the jfxrt.jar to the External jars for the project.
I was able to run the application.
Also please use the tutorials from this page as they are relevant for the latest release of JavaFX
Shikha Upadhyaya
Ranch Hand

Joined: Aug 17, 2011
Posts: 70

Mohamed Sanaulla wrote:I used Eclipse Helios to run JavaFX application and it works. I didnt install any JavaFX plugin for Eclipse.
Also I created a simple Java project and then added the following:


I also added the jfxrt.jar to the External jars for the project.
I was able to run the application.
Also please use the tutorials from this page as they are relevant for the latest release of JavaFX

Oh then *Eclipse Indigo* is the problem!!
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

Oh then *Eclipse Indigo* is the problem!!

I dont think it should be the problem.
What is the version of JRE you are using when you are trying to run the application? What matters here would be the JavaFX library and the runtime and the compatible JRE version.
Shikha Upadhyaya
Ranch Hand

Joined: Aug 17, 2011
Posts: 70

Mohamed Sanaulla wrote:I dont think it should be the problem.
What is the version of JRE you are using when you are trying to run the application? What matters here would be the JavaFX library and the runtime and the compatible JRE version.

When I created the project I had checked JavaSE 1.6 as the execution environment JRE in the New Java Project window.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

Shikha Upadhyaya wrote:
Mohamed Sanaulla wrote:I dont think it should be the problem.
What is the version of JRE you are using when you are trying to run the application? What matters here would be the JavaFX library and the runtime and the compatible JRE version.

When I created the project I had checked JavaSE 1.6 as the execution environment JRE in the New Java Project window.


I think JavaFX 2 required Java SE 7, so you would have to change in the preferences to use Java 7
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The import javafx cannot be resolved