1

I am trying to use JavaFX package in a Java 8 code from eclipse plug-in. I was able to compile it, but at run-time the plug-in is not able get JavaFX class loaded. Looks like, OSGi Plug-in is not able load classes from "[JAVA]\jre\lib\ext\" directory, but able to load classes from "[JAVA]\jre\lib\". Any pointers how to resolve the issue is highly appreciated.

** I understand there is a way off e(fx)clipse or copying jfxrt.jar to the plug-in class-path will resolve the issue, but I wanted to know why plug-in is not able to load from /ext/ path of the JRE.

ctangudu
  • 84
  • 5
  • See [_"Java vs OSGi Class Loading"_ blog post by Sathya Bandara](https://medium.com/@technospace/java-vs-osgi-class-loading-17a1ad4cc2a5) – howlger Sep 11 '18 at 20:41
  • I understand, but as I don't have JavaFX as plug-in, I cannot access JavaFX through "Import-Package" in manifest.mf – ctangudu Sep 11 '18 at 21:41
  • In your `META-INF/MANIFEST.MF` is `Bundle-RequiredExecutionEnvironment` set and if yes, to which value? – howlger Sep 12 '18 at 06:36
  • The value for 'Bundle-RequiredExecutionEnvironment' is **JavaSE-1.8** in MANIFEST.MF. – ctangudu Sep 12 '18 at 13:59
  • This means only the packages that are specified by the `JavaSE-1.8` profile (see [here property `org.osgi.framework.system.packages`](https://git.eclipse.org/c/equinox/rt.equinox.framework.git/tree/bundles/org.eclipse.osgi/JavaSE-1.8.profile#n14)) can be accessed. For more details see [this answer](https://stackoverflow.com/a/52019047). – howlger Sep 12 '18 at 14:45
  • Thanks, you are right. It doesn't load these classes.But got the solution, as following. – ctangudu Sep 13 '18 at 15:06

1 Answers1

2

As mentioned in the following link Unresolved JavaFX packages in OSGi Felix Application, we did the following steps to fix the issue. The following are the OSGi configuration properties.

org.osgi.framework.bundle.parent - Specifies which class loader is used for boot delegation. Possible values are: boot for the boot class loader, app for the application class loader, ext for the extension class loader, and framework for the framework's class loader. The default is boot.

org.osgi.framework.system.packages - Specifies a comma-delimited list of packages that should be exported via the System Bundle from the framework class loader. The framework will set this to a reasonable default. If the value is specified, it replaces any default value.

So by adding

-Dorg.osgi.framework.bundle.parent=ext  
-Dorg.osgi.framework.system.packages.extra=javafx.* 

the VM args, it added required dependency.

kleopatra
  • 51,061
  • 28
  • 99
  • 211
ctangudu
  • 84
  • 5