Saturday, 3 November 2012

How to configure JavaFX 2.2 in Eclipse Juno

Despite NetBeans has a great integration with JavaFX, there are many people that prefer to code on Eclipse. If you are one of them check this out:

Download e(fx)clipse

There is a project called e(fx)clipse that integrate some tools to start new JavaFx projects without to define the library by your self.  In essence, you download a precompiled Eclipse that include the options to create your own FXML files and JavaFX projects. There are lazy, adventurous and coward Install methods. I recommend you the adventurous  method, which is an installation of e(FX)clipse  as an extension of the IDE.

I would like to emphasize that there is a lazy version you can download from efxclipse.org, which is easier and faster.

In this place you will find the instructions:
http://efxclipse.org/install.html

Well, this is how I get the plugin installed in Eclipse Juno...
First I had to install Xtext.
In Eclipse tab Help/Install new software. In this window press Add.. button and add  the repositories:
http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/


 It is important to check "Contact all update sites during install to find required software" I selected the Xtext-2-3-1 since I am working with Eclipse Juno.


After install Xtext you can install e(fx)clipse plugin. The same process than before;  Help/Install new software. In this window press Add...  and copy/paste  this address: http://www.efxclipse.org/p2-repos/releases/latest/  . In my case, I deselected e4 because was already installed in Eclipse.Otherwise I got an error


That is how my Install details looks like before the process installation.

With this plug in it is possible to create a JavaFX project, which contains the jfxrt.jar by default.
Now you can create a new JavaFX project: right click on Eclipse package explorer: New--->Other---->JavaFX--->JavaFX Project

Manually Importing JavaFX

The other option is to import manually the jfxrt file when for instance, you want to just try JavaFX. In order to use the JavaFX libraries, you have to import the jfxrt.jar into your build path.
The file is on your java folder. In windows: C:\Program Files\Java\jdk1.7.0_09\jre\lib\jfxrt.jar
In Linux depending on where did you installed your Oracle Java:  yourPath/jdk1.7.0_09/jre/lib/jfxrt.jar

How do I Import an external Library? 

 

 Right click in your project the JRE System Library that is in your Eclipse Project, then select Build Path and finally Configure Build Path

 
 In this window press Add External JARs...

Where do I find jfxrt.jar file? 

 

 Here point to your Java folder that contain the jfxrt.jar (C:\Program Files\Java\jdk1.7.0_09\jre\lib\jfxrt.jar in windows)

Good JafaFx coding in Eclipse!

3 comments:

  1. To download javafx plugin use this URL:

    http://download.java.net/general/openjfx/plugins/eclipse/site.xml

    ReplyDelete
  2. On: Manually Importing JavaFX - You better add the JavaFX-Library because then sharing your project with others is easier

    ReplyDelete
  3. thank you
    text is very useful....

    ReplyDelete