Skip to main content



      Home
Home » Eclipse Projects » e(fx)clipse » javaFX in e4 vs Java application(FXCanvas class not found by classloader)
javaFX in e4 vs Java application [message #1308936] Tue, 22 April 2014 07:13 Go to next message
Eclipse UserFriend
I am using e4 Kepler (not e(fx) for this particular application).

I am using the SwtJavaFxInteroperabilityDemo as a test of a javaFX component embedded in a SWT application (http://www.javaworld.com/article/2074496/core-java/integrating-javafx-2-0-with-swing-and-swt.html).

I created a plugin project and ran fine using jdk1.7 + plugin from existing jar (jfxswt.jar) or using jdk1.8.

I then modified the plugin to accept a Composite, that was passed in from an e4 application:
public class SwtJavaFxInteroperabilityTrial {
public void showFxCanvas(Composite comp) {
final Shell shell = comp.getShell();
shell.setText("JavaFX / SWT Integration");
shell.setLayout(new FillLayout());
final FXCanvas canvas = new FXCanvas(shell, SWT.NONE);
final Scene scene = TextIntegrationSceneCreator.createTextScene();
canvas.setScene(scene);
shell.open();
}
}
When I then tried running the class, the e4 DefaultClassLoader could not find the FXCanvas class. (I tried using JDK1.8 for both e4 app and javafx plugin, and jdk1.7 + plugin from existing jar (jfxswt.jar)).

How can I get the e4 class loader to recognize javafx.embed.swt.FXCanvas?

Cheers

Don
Re: javaFX in e4 vs Java application [message #1308969 is a reply to message #1308936] Tue, 22 April 2014 07:35 Go to previous messageGo to next message
Eclipse UserFriend
On 22.04.14 13:13, Don Smyth wrote:
> I am using e4 Kepler (not e(fx) for this particular application).
>
> I am using the SwtJavaFxInteroperabilityDemo as a test of a javaFX
> component embedded in a SWT application
> (http://www.javaworld.com/article/2074496/core-java/integrating-javafx-2-0-with-swing-and-swt.html).
>
>
> I created a plugin project and ran fine using jdk1.7 + plugin from
> existing jar (jfxswt.jar) or using jdk1.8.

This is a bad idea because then your jfxswt.jar does not match the other
JavaFX APIs - e.g. jfxswt.jar is available only on JDK8 and there's not
guarantee that it does not call API only available on JDK8 with the
matching version while it maybe works today there's not guarantee to
work in future.

>
> I then modified the plugin to accept a Composite, that was passed in
> from an e4 application:
> public class SwtJavaFxInteroperabilityTrial {
> public void showFxCanvas(Composite comp) {
> final Shell shell = comp.getShell();
> shell.setText("JavaFX / SWT Integration");
> shell.setLayout(new FillLayout());
> final FXCanvas canvas = new FXCanvas(shell, SWT.NONE);
> final Scene scene = TextIntegrationSceneCreator.createTextScene();
> canvas.setScene(scene);
> shell.open();
> }
> }

This code is just wrong IMHO why you'll add the FXCanvas to the shell
and not to the composite you get passed in anyways this not your real
problem.

> When I then tried running the class, the e4 DefaultClassLoader could not
> find the FXCanvas class. (I tried using JDK1.8 for both e4 app and
> javafx plugin, and jdk1.7 + plugin from existing jar (jfxswt.jar)).
>
> How can I get the e4 class loader to recognize javafx.embed.swt.FXCanvas?

a) remove your repackaged swtfx.jar
b) add package javafx imports in your bundle (make sure your don't miss
any for packages your reference - i often simply add all that start
with javafx)
c) add the following deps to your launch config:
- org.eclipse.fx.javafx
- org.eclipse.fx.osgi
d) launch the application with inside your VM arguments
-Dosgi.framework.extensions=org.eclipse.fx.osgi

Tom
Re: javaFX in e4 vs Java application [message #1309083 is a reply to message #1308969] Tue, 22 April 2014 09:08 Go to previous messageGo to next message
Eclipse UserFriend
Thanks Tom for the prompt reply.

Thanks for tip Re: composite.

I followed your instructions:
(Using JDK1.8.0 64bit)
a) I removed the swtfx.jar plugin.
b) I added all javax packages to the dependencies of the plugin that uses javaFX.
c) to the product run configuration I made sure the org.eclipse.fx.javafx and org.eclipse.fx.osgi were selected in the target platform.
d) I added -Dosgi.framework.extensions=org.eclipse.fx.osgi to the VM Arguments in the product launching arguments.

on running the application i still get the error:
org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError: javafx/embed/swt/FXCanvas)
Caused by: java.lang.NoClassDefFoundError: javafx/embed/swt/FXCanvas
Caused by: java.lang.ClassNotFoundException: javafx.embed.swt.FXCanvas cannot be found by ...application_1.0.0.qualifier

I am obviously not doing something correctly but am unclear as to what.

Cheers

Don
Re: javaFX in e4 vs Java application [message #1309127 is a reply to message #1309083] Tue, 22 April 2014 09:41 Go to previous messageGo to next message
Eclipse UserFriend
Which version of the 2 bundles? Please note they have to be part of your
launch config.

To check if they are running you can add adding
-Defxclipse.osgi.hook.debug=true and you should get some output on the
command line

Tom

On 22.04.14 15:08, Don Smyth wrote:
> Thanks Tom for the prompt reply.
>
> Thanks for tip Re: composite.
>
> I followed your instructions:
> (Using JDK1.8.0 64bit)
> a) I removed the swtfx.jar plugin.
> b) I added all javax packages to the dependencies of the plugin that
> uses javaFX.
> c) to the product run configuration I made sure the
> org.eclipse.fx.javafx and org.eclipse.fx.osgi were selected in the
> target platform.
> d) I added -Dosgi.framework.extensions=org.eclipse.fx.osgi to the VM
> Arguments in the product launching arguments.
>
> on running the application i still get the error:
> org.eclipse.swt.SWTException: Failed to execute runnable
> (org.eclipse.e4.core.di.InjectionException:
> java.lang.NoClassDefFoundError: javafx/embed/swt/FXCanvas)
> Caused by: java.lang.NoClassDefFoundError: javafx/embed/swt/FXCanvas
> Caused by: java.lang.ClassNotFoundException: javafx.embed.swt.FXCanvas
> cannot be found by ...application_1.0.0.qualifier
>
> I am obviously not doing something correctly but am unclear as to what.
>
> Cheers
>
> Don
Re: javaFX in e4 vs Java application [message #1310119 is a reply to message #1309127] Tue, 22 April 2014 23:07 Go to previous message
Eclipse UserFriend
Thanks Tom,

I now have javaFX is working within SWT Smile
I installed the latest e(fx) 4.3.2 (I was using Kepler 4.3.1).
I note there are two places one can set the VM args - in the product launching tab, and in the product run configuration arguments. The -Dosgi.framework.extensions=org.eclipse.fx.osgi needs to be in the product run configuration arguments.

I appreciate your help.

Cheers

Don
Previous Topic:Opening a dialog from within a dialog
Next Topic:e(fx)clipse runtime in 3.8 and/or Java 7
Goto Forum:
  


Current Time: Tue Apr 29 18:19:32 EDT 2025

Powered by FUDForum. Page generated in 0.07098 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top