ndrw
ndrw

Reputation: 773

How to embed JavaFX into eclipse rcp view

I am trying to use JavaFX 2 from a simple eclipse view, but I am getting an

java.lang.UnsatisfiedLinkError: Invalid URL for class: bundleresource://435.fwk1827795025/com/sun/glass/utils/NativeLibLoader.class

After some investigation with JAD I have found out that NativeLibLoader has very interesting check:

if(!classUrlString.startsWith("jar:file:") || classUrlString.indexOf("!") == -1)
    throw new UnsatisfiedLinkError((new StringBuilder()).append("Invalid URL for class: ").append(classUrlString).toString());

Does this mean that javafx can't be used from OSGi bundle? Please prove me wrong.

Upvotes: 4

Views: 4281

Answers (4)

test1
test1

Reputation: 1

Pls. follow this simple steps:

  1. Create "Plugin from Existing JAR Archives" in Eclipse

    • add External ..jre/lib/jfxrt.jar (from jdk1.7)
    • click Target Platform "an OSGI framework" !
    • unselect "Unzip".
  2. Click META-INF/MANIFEST.MF - in Runtime tab Export all Packages (with "Add").

  3. Add the created "Fx_Osgi_Plugin" as required plugin in "Dependencies" tab for each plugin.xml.

  4. In .product click "Add Required Plug-ins" in Dependencies tab.

Now plugins using Java-Fx have reference to an Osgi Java-Fx Version.

Upvotes: 0

Aykut Kllic
Aykut Kllic

Reputation: 937

e(fx)clipse now has a wizard for this. Please take a look at: http://www.efxclipse.org/trac/wiki/Tutorial2

You can quickly test your view with this hello world code:

public class MyViewPart extends FXViewPart {

    @Override
    protected Scene createFxScene() {
        Button btn = new Button();
        btn.setText("Say 'Hello World!'");
        btn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent arg0) {
                System.out.println("Hello World!");
            }
        });
        StackPane root = new StackPane();
        root.getChildren().add(btn);

        return new Scene(root,300,200);
    }

    @Override
    protected void setFxFocus() {}
}

Upvotes: 0

tomsontom
tomsontom

Reputation: 5897

I've just released a step by step tutorial how to create and export an Eclipse ViewPart that uses JavaFX 2.0. See http://www.efxclipse.org/trac/wiki/Tutorial3

Upvotes: 2

jewelsea
jewelsea

Reputation: 159566

Updates to the JavaFX loader to be more friendly with OSGI are scheduled for the "Lombard" release (which is the JavaFX 3.0 timeframe, i.e. 2013). Until then, you may encounter issues working with JavaFX from an OSGI bundle. Other OSGI related issues can be found by searching for OSGI in the JavaFX Jira (anybody can signup to view the bugs and issues listed there). Tom Schindl, the creator of the e(fx)clipse plugin for JavaFX in Eclipse, would be the best contact point with experience in integrating JavaFX within Eclipse.

Upvotes: 1

Related Questions