3

It has been suggested that part of the solution of the problem with javafx classloading and osgi is to move jfxrt to the Java installation lib/ext directory so that it is loaded when the JVM starts.

If this is done in a private install of Java the javafx classes are available at design time but are not found at run time when a javafx bundle is installed.

Is it possible that this can be made to work?

I am using felix and bndtools in eclipse as dev environment on Ubuntu 12.04.

Puce
  • 37,247
  • 13
  • 80
  • 152
paulf
  • 93
  • 7

2 Answers2

3

First, the bundles that are using javafx packages must import them with Import-Package.

Next you need to get the system bundle to export the packages. By default the system bundle only exports the standard JRE packages plus the OSGi framework packages; you can extend this by setting the property org.osgi.framework.system.packages.extra. Since you are using Bndtools (good!) you can set the property as follows:

-runsystempackages: javafx.foo,javafx.bar...
Neil Bartlett
  • 23,743
  • 4
  • 44
  • 77
  • Using bndtools, how are the Import-Package details entered? – paulf Dec 18 '12 at 12:08
  • If they are entered in the source and resolve is run all the detail in the run tab disappears. The only other option seems to be to add a bundle to the run requirements and how is this done with the jfxrt jar? – paulf Dec 18 '12 at 12:12
  • The import package statement is added to the bundle automatically, based on the packages that you actually use in your code. I.e. if you use package `org.foo` in your code, bnd will add `org.foo` to your `Import-Package`. You should not write `Import-Package` manually. – Neil Bartlett Dec 19 '12 at 01:26
  • Regarding your second comment: jfxrt.jar shouldn't be added as a bundle because (a) Oracle intended it to be uses as part of the extension library of the JRE itself, and (b) it's not a bundle anyway. Since it's already part of the JRE, you just need to give your OSGi bundles access to it using the `-runsystempackages` instruction. – Neil Bartlett Dec 19 '12 at 01:28
1

I have recently released a first Early Access version of Drombler FX, a modular Rich Client Platform for JavaFX based on OSGi and Maven (POM-first).

You can read more about it here: http://puces-blog.blogspot.ch/2012/12/drombler-fx-building-modular-javafx.html

Getting Startet: http://wiki.drombler.org/GettingStarted

The generated output is explained here: http://wiki.drombler.org/GettingStarted#drombler-fx-sample-application-the-binaries-explained

(I didn't have to move any JavaFX JARs.)

Puce
  • 37,247
  • 13
  • 80
  • 152