How to embed JavaFX into eclipse rcp view

℡╲_俬逩灬. 提交于 2019-12-07 11:14:44

问题


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.


回答1:


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.




回答2:


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




回答3:


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() {}
}



回答4:


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.



来源:https://stackoverflow.com/questions/9368925/how-to-embed-javafx-into-eclipse-rcp-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!