JavaFX applications depend on packages from the JavaFX APIs, such as javafx.application
and several others. Since it looks like you have built your bundle with Maven Bundle Plugin, your bundle already has these dependencies declared. This is a good thing.
In Java 8 the javafx.*
packages are provided by the base JRE. However OSGi does not automatically export every package from the JRE, simply because all JREs have a bunch of non-standard packages (e.g. com.sun.*
etc) that normal application code should not have access to. Therefore OSGi only makes available the packages that are defined by the relevant JCP Specification for the version of Java that you are using. For example packages such as javax.swing
, org.w3c.dom
, etc.
Since JavaFX is not a standard, there is no JCP Specification for JavaFX, and OSGi does not export the javafx.*
packages. However you can configure OSGi to do this for you by setting the following configuration property when you launch OSGi:
org.osgi.framework.system.packages.extra=javafx.application,...
NB I have shown how to add the javafx.application
package to your runtime. It is likely you will need to add several more, i.e. all of the packages from the JavaFX API. I am not sufficiently familar with JavaFX to list these, but they should be easy enough for you to find.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…