javafx package javafx.embed.swt not in java8u5

2019-01-28 03:30发布

问题:

I'd like to use FXCanvas from the package javafx.embed.swt as shown in this example: http://docs.oracle.com/javafx/2/swt_interoperability/jfxpub-swt_interoperability.htm# But all I can find is javafx.embed.swing package. javafx.embed.swt is simply not existant. What am I doing wrong ? I use java8u5. Is there a special download nessessary or is there a different version of java that contains that package ??

thanks for any hint! Thorsten

回答1:

The JavaFX SWT embedding classes are in the jre/lib directory.

$ java -version
java version "1.8.0_20-ea"
Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b14, mixed mode)

$ pwd
/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib

$ ls jfxswt.jar 
jfxswt.jar

$ jar tvf jfxswt.jar | grep FXCanvas.class
18702 Mon May 12 21:52:14 PDT 2014 javafx/embed/swt/FXCanvas.class

I've never used SWT in JavaFX so I don't really know anything about how to use it. If you would like more assistance, post to the e(fx)clipse forums for advice - they are experts on such matters.

Also refer to the version of the documentation which matches the version of Java you are using:

  • 8 JavaFX Interoperability with SWT.


回答2:

This because the package javafx.embed.swt was moved from the /lib/ext/jfxrt.jar to /lib/jfxswt.jar. You need to add this last explicitly to see the FXCanvas class.
This is the link to the issue: Separate javafx.embed.swt from jfxrt.jar