Reputation: 773
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
Reputation: 1
Pls. follow this simple steps:
Create "Plugin from Existing JAR Archives" in Eclipse
Click META-INF/MANIFEST.MF - in Runtime tab Export all Packages (with "Add").
Add the created "Fx_Osgi_Plugin" as required plugin in "Dependencies" tab for each plugin.xml.
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
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
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
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