How to embed JavaFX in an eclipse rcp view

I try to use JavaFX 2 from a simple eclipse view, but I get

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

After some investigation with JAD, I found that NativeLibLoader has a 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 cannot be used from the OSGi package? Please prove that I'm wrong.

+4
source share
4 answers

JavaFX loader updates for OSGI-friendly ones are planned for the release of Lombard (which is the JavaFX 3.0 timeframe , i.e. 2013). Until then, you may encounter problems related to JavaFX from the OSGI package. Other OSGI-related issues can be found by searching for OSGI in JavaFX Jira (anyone can register to view the errors and issues listed there). Tom Schindl , creator of the e (fx) clip -on plug-in for JavaFX in Eclipse, would be the best contact point with experience integrating JavaFX in Eclipse.

+1
source

I just released a walkthrough on creating and exporting Eclipse ViewPart using JavaFX 2.0. See http://www.efxclipse.org/trac/wiki/Tutorial3

+2
source

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

You can quickly check your opinion 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() {} } 
0
source

Pls. follow these simple steps:

  • Create a "Plugin from Existing JAR Archives" in Eclipse

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

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

  • In .product, click "Add Required Plugins" on the "Dependencies" tab.

Now plugins using Java-Fx have a link to the Osgi Java-Fx Version.

0
source

Source: https://habr.com/ru/post/1397507/


All Articles