Hello Tom,
I wrote you a few years ago in the e(fx)clipse forum (2014) that I implemented the SceneBuilder as an Eclipse plugin (please scroll down), see:
https://www.eclipse.org/forums/index.php/t/796180/
YouTube:
The SceneBuilder Kit is integrated into a scientific RCP application (statistics, image analysis, modeling environment, etc.) which I develop since 2004:
https://bio7.org
One feature of this application is to compile Java dynamically (in process compilation) and to create Java GUI's with JavaFX or SWT on the fly. Here an older overview of Bio7:
The idea behind the integration and dynamic compilation is to allow other users to create easily software inside Bio7 reusing all integrated API's
(R statistics, ImageJ, Java Scientific libs, SWT, JavaFX etc.) and special modeling components (Custom perspective and views, etc.) in an very easy way.
The integration of JavaFX is done in the plugins via the Bundle-ClassPath as described in the e(fx)clipse forum above (Java 11 will be bundled with the RCP!):
Bundle-ClassPath:
bin/,
src/,
external:$java.home$/lib/javafx-swt.jar,
This worked for years and even now (with the exception of the classloader bug analyzed by Kevin)
Gesendet: Freitag, 05. Oktober 2018 um 09:27 Uhr
Von: "Tom Schindl" <***@bestsolution.at>
An: open <openjfx-***@openjdk.java.net>
Betreff: Re: Aw: Re: Re: "Toolkit already initialized" error with OpenJDK 11
So how do you then load FXCanvas? It will not be found on any classpath
unless you ship the FXCanvas class directly which as you see is a bad idea.
I'm naturally biased but I think the approach take by e(fx)clipse is the
right one as it makes sure there's ever only one instance of FXCanvas
loaded in your runtime.
There is more static stuff in FXCanvas (eg Transfer and DropTargets) who
might or might not cause problems.
BTW IIRC the SceneBuilder Eclipse integration [1] is using e(fx)clipse
to load the FXCanvas.
Tom
[1]https://gitlab.stud.iie.ntnu.no/tobiaas/scene-builder-plugin
Hello Tom,
thanks for the answer. However I don't use e(fx)clipse to integrate
Javafx panels in SWT and a Rich Client Platform.
I believe that Kevin found the problem related to different classloaders
*Gesendet:* Donnerstag, 04. Oktober 2018 um 16:44 Uhr
*Betreff:* Re: Aw: Re: "Toolkit already initialized" error with OpenJDK 11
Hi,
Just to make sure I understand. Do you say that other OSGi-Bundles bring
with them their own FXCanvas?
I've been looking at the e(fx)clipse code [1] who deals with FXCanvas,
... but I can't think of a situation where we create multiple classloaders.
Tom
[1]
https://github.com/eclipse/efxclipse-rt/blob/3.x/modules/core/org.eclipse.fx.osgi/src/main/java/org/eclipse/fx/osgi/fxloader/FXClassLoader.java[https://github.com/eclipse/efxclipse-rt/blob/3.x/modules/core/org.eclipse.fx.osgi/src/main/java/org/eclipse/fx/osgi/fxloader/FXClassLoader.java]
"java.lang.IllegalStateException: Toolkit already initialized".
Post by marcel Austenfeld However I found out that this error only occurs if I call SWT FXCanvas
classes located in different Eclipse plugins.
Post by marcel Austenfeld I can create multiple JavaFX canvas if they are located in one Eclipse
plugin.
Post by marcel Austenfeld Vice versa if I try to to open the JavaFX SceneBuilder canvas which is
located in a seperate Eclipse plugin this error occurs again.
Post by marcel Austenfeld So I wonder that beginning with Java 9 the JavaFX toolkit doesn't
recognize an already started toolkit in another Eclipse plugin (which
was definitely the case with Java 8!).
Post by marcel Austenfeld Maybee this has something to do with the new module system of Java >=9?
Gesendet: Mittwoch, 26. September 2018 um 14:09 Uhr
Betreff: Re: "Toolkit already initialized" error with OpenJDK 11
I'm' not aware of anything that intentionally changed between FX in JDK
8 and FX 11, but my guess is that the FX runtime is being shutdown after
your first FXCanvas exits. Try making the following call (only needed
Platform.setImplicitExit(false);
-- Kevin
Post by marcel AustenfeldFirst of all congratulation to the new release and thank you for the
hard work on JavaFX.
Post by marcel AustenfeldPost by marcel AustenfeldI have a problem with JavaFX which in my case is embedded in a Rich
Client Platform of Eclipse.
Post by marcel AustenfeldPost by marcel AustenfeldI integrated several SWT FXCanvas (some with SwingNode panels as a
SWT_AWT replacement) into my app.
Post by marcel AustenfeldPost by marcel AustenfeldThis works fine in Java 8 which my current release depends on.
However in Java 11 after the second panel is initialized at startup I
"Caused by: java.lang.IllegalStateException: Toolkit already initialized"
Is there a new option available to avoid a new initialization of the
toolkit if several FXCanvas are embedded in an application?
Post by marcel AustenfeldPost by marcel AustenfeldOr do you now any changes since Java 8 which could the cause of such
an exception?
--
Tom Schindl, CTO
BestSolution.at EDV Systemhaus GmbH
Eduard-Bodem-Gasse 5-7. A-6020 Innsbruck
Reg. Nr. FN 222302s am Firmenbuchgericht Innsbruck
--
Tom Schindl, CTO
BestSolution.at EDV Systemhaus GmbH
Eduard-Bodem-Gasse 5-7. A-6020 Innsbruck
Reg. Nr. FN 222302s am Firmenbuchgericht Innsbruck