Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » jfxswt not on the classpath
jfxswt not on the classpath [message #1403513] Thu, 24 July 2014 09:20 Go to next message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 135
Registered: July 2009
Senior Member
Hello,

i'm not sure if this is the right forum to ask.

However in my application (RCP)i have a bundled jre (if exported) and in the application i use a JavaFX canvas (embedded in swt).

The jfxswt.jar doesn't work by default because it is not in the /ext directory of the jre. If i put the lib there everything seems to be on the classpath of my application (No compile errors).

However if i startup the RCP product (from within Eclipse) and then open the embedded JavaFX canvas i get the following error: org/eclipse/swt/widgets/Canvas not found....

If i put jfxswt.jar in an Eclipse plugin instead and export the packages for the RCP everything works fine.

My questions are:

Why is jfxswt not on the classpath or can't find swt. How can i bundle this library correctly in an RCP with a jre so that my application can use the jfxswt.jar classes.

Or would it be legal to copy the jfxswt.jar in a Eclipse plugin?

Thanks in advance for any help or information.



Re: jfxswt not on the classpath [message #1403526 is a reply to message #1403513] Thu, 24 July 2014 09:53 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5673
Registered: July 2009
Senior Member
Hi,

On 24.07.14 11:20, Marcel A. wrote:
> Hello,
>
> i'm not sure if this is the right forum to ask.
> However in my application (RCP)i have a bundled jre (if exported) and in
> the application i use a JavaFX canvas (embedded in swt).
>
> The jfxswt.jar doesn't work by default because it is not in the /ext
> directory of the jre. If i put the lib there everything seems to be on
> the classpath of my application (No compile errors).
> However if i startup the RCP product (from within Eclipse) and then open
> the embedded JavaFX canvas i get the following error:
> org/eclipse/swt/widgets/Canvas not found....

Right the reason is that the classloader which loads the FXCanvas must
also be able to access the SWT library so if you copy the jar it is on
the extension-classloader which naturally can not see SWT.

>
> If i put jfxswt.jar in an Eclipse plugin instead and export the packages
> for the RCP everything works fine.
>

That's not a good idea because FXCanvas makes use of internal JavaFX
APIs who can change from release to release. Your only advantage is that
because you ship the jre with the product you are under full control so
this might be an option if you let the legal part aside.

> My questions are:
> Why is jfxswt not on the classpath or can't find swt. How can i bundle

See above the reason which something on the ext-classpath can't find SWT
- if you want to see how we make this work can be seen in [1]

> this library correctly in an RCP with a jre so that my application can
> use the jfxswt.jar classes.
>

I would suggest you make use of org.eclipse.fx.ui.workbench3 this way
your UI does not need FXCanvas at compile time and then you make use of
org.eclipse.fx.osgi and org.eclipse.fx.javafx to get stuff appropiately
wired at runtime.

> Or would it be legal to copy the jfxswt.jar in a Eclipse plugin?
>

I'm not a lawyer so I can not really comment on if this is legal - the
best chance I see is that when you do this with open-jdk I doubt you can
do this with Oracle JDK.

I would suggest you use:
a) don't repackage you don't have any legal problems
b) keep jfxswt.jar out of ext else you get the classloader problem
c) you make use of our classloader hooks.

BTW we have a nice tutorial explaining how to make javafx work inside an
RCP see [2]

Tom

[1]http://git.eclipse.org/c/efxclipse/org.eclipse.efxclipse.git/tree/bundles/runtime/org.eclipse.fx.osgi/src/org/eclipse/fx/osgi/fxloader/FXClassLoader.java
[2]http://wiki.eclipse.org/Efxclipse/Tutorials/Tutorial2
Re: jfxswt not on the classpath [message #1403541 is a reply to message #1403526] Thu, 24 July 2014 10:28 Go to previous messageGo to next message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 135
Registered: July 2009
Senior Member
Hello Tom,

thanks for your fast reply and help. Great links.

However how would i apply the classloader hook in [1] in my RCP product to load the FX classes?


Re: jfxswt not on the classpath [message #1403545 is a reply to message #1403541] Thu, 24 July 2014 10:39 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5673
Registered: July 2009
Senior Member
You need to have the following bundles in your target platform:
* org.eclipse.fx.osgi
* org.eclipse.fx.javafx
* org.eclipse.fx.workbench3

and then all you need to make sure is that at dev time you launch with
-Dosgi.framework.extensions=org.eclipse.fx.osgi in your vm-arguments -
case you are assembeling the final product with the p2-director (e.g.
with maven-tycho) there's no more work needed because the p2-director
creates an entry in your config.ini.

If you want to see if the hook is active you need to pass
-Defxclipse.osgi.hook.debug=true which will give you informations on
what's going on under the covers.

Final note: If you target platform is NOT built from p2-repos but e.g.
the rcp stuff is referenced through a directory it is important that
instead of adding the p2 repo with the above bundles you need to copy
them over to your RCP-Target because org.eclipse.fx.osgi HAS TO reside
physically next to org.eclipse.osgi!

Tom


On 24.07.14 12:28, Marcel A. wrote:
> Hello Tom,
>
> thanks for your fast reply and help. Great links.
>
> However how would i apply the classloader hook in [1] in my RCP product
> to load the FX classes?
>
>
>
Re: jfxswt not on the classpath [message #1403554 is a reply to message #1403545] Thu, 24 July 2014 11:43 Go to previous messageGo to next message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 135
Registered: July 2009
Senior Member
Hello Tom,

i have a feature based product with plugins references in a "classical" directory.

i've installed efxclipse from your update site.

Which plugins or feature do i have to add to my main plugin or product configuration?

Do i still need: -Dosgi.framework.extensions=org.eclipse.fx.osgi?







Re: jfxswt not on the classpath [message #1403561 is a reply to message #1403554] Thu, 24 July 2014 12:02 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5673
Registered: July 2009
Senior Member
There should be a feature named "org.eclipse.fx.target.rcp.feature"
which holds exactly the 3 bundles you need. IIRC you still need the -D
when launching from an inner eclipse but you could give it a try without it.

Please note that if you installed the tooling into your eclipse you'll
still miss o.e.f.workbench3 and the above mentioned feature, so please
add http://download.eclipse.org/efxclipse/runtime-released/0.9.0/site to
your target platform as described in the tutorial (Step 9 & 10) because
the adapter hook is part of your classic install dir things should
operate without problems.

Tom

On 24.07.14 13:43, Marcel A. wrote:
> Hello Tom,
>
> i have a feature based product with plugins references in a "classical"
> directory.
>
> i've installed efxclipse from your update site.
> Which plugins or feature do i have to add to my main plugin or product
> configuration?
>
> Do i still need: -Dosgi.framework.extensions=org.eclipse.fx.osgi?
>
>
>
>
>
>
>
>
Re: jfxswt not on the classpath [message #1403565 is a reply to message #1403561] Thu, 24 July 2014 12:39 Go to previous messageGo to next message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 135
Registered: July 2009
Senior Member
Hello Tom,

i added the org.eclipse.fx.target.rcp.feature and followed the steps 9&10.
However if i add the -D flag then i get the error below:

java.lang.NoClassDefFoundError: org/eclipse/osgi/baseadaptor/HookConfigurator
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:259)
at org.eclipse.osgi.internal.hookregistry.HookRegistry.loadConfigurators(HookRegistry.java:185)
at org.eclipse.osgi.internal.hookregistry.HookRegistry.initialize(HookRegistry.java:106)
at org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(EquinoxContainer.java:73)
at org.eclipse.osgi.launch.Equinox.<init>(Equinox.java:31)
at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:297)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:232)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Caused by: java.lang.ClassNotFoundException: org.eclipse.osgi.baseadaptor.HookConfigurator
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 27 more

Do you have any idea what i'm doing wrong? Without the flag the canvas cannot be loaded.

[Updated on: Thu, 24 July 2014 12:40]

Report message to a moderator

Re: jfxswt not on the classpath [message #1403576 is a reply to message #1403565] Thu, 24 July 2014 13:10 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5673
Registered: July 2009
Senior Member
on what platform are you luna or kepler. It is important that you use
the matching p2 repo, to me it looks like you added the Kepler p2-repo
(=0.9.0) but the rest of your platform is Luna.

Tom

On 24.07.14 14:39, Marcel A. wrote:
> Hello Tom,
>
> i added the org.eclipse.fx.target.rcp.feature and followed the steps 9&10.
> However if i add the -D flag then i get the error below:
>
> java.lang.NoClassDefFoundError:
> org/eclipse/osgi/baseadaptor/HookConfigurator
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
> at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
> at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
> at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:259)
> at
> org.eclipse.osgi.internal.hookregistry.HookRegistry.loadConfigurators(HookRegistry.java:185)
>
> at
> org.eclipse.osgi.internal.hookregistry.HookRegistry.initialize(HookRegistry.java:106)
>
> at
> org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(EquinoxContainer.java:73)
>
> at org.eclipse.osgi.launch.Equinox.<init>(Equinox.java:31)
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:297)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:232)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
> at java.lang.reflect.Method.invoke(Method.java:483)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
> Caused by: java.lang.ClassNotFoundException:
> org.eclipse.osgi.baseadaptor.HookConfigurator
> at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> ... 27 more
>
> Do you have any idea what i'm doing wrong?
Re: jfxswt not on the classpath [message #1403583 is a reply to message #1403576] Thu, 24 July 2014 13:50 Go to previous messageGo to next message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 135
Registered: July 2009
Senior Member
Hello Tom,

i don't want to bother any further. No i got no errors anymore by reinstalling everything but at runtime the canvas is still not available.

Thanks again for your time and patience.
Re: jfxswt not on the classpath [message #1403590 is a reply to message #1403583] Thu, 24 July 2014 14:01 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5673
Registered: July 2009
Senior Member
Did you do a package import for javafx.embed.swt in your MANIFEST.MF?
Please always provide the output. Do you see the hook being loaded?

Tom

On 24.07.14 15:50, Marcel A. wrote:
> Hello Tom,
>
> i don't want to bother any further. No i got no errors anymore by
> reinstalling everything but at runtime the canvas is still not available.
>
> Thanks again for your time and patience.
Re: jfxswt not on the classpath [message #1403612 is a reply to message #1403590] Thu, 24 July 2014 15:04 Go to previous messageGo to next message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 135
Registered: July 2009
Senior Member
Hello Tom,

i will continuou tomorrow. Thanks for your help.
Re: jfxswt not on the classpath [message #1406873 is a reply to message #1403590] Mon, 11 August 2014 10:25 Go to previous message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 135
Registered: July 2009
Senior Member
Hello Tom,

i want to give you a feedback about embedding jfxswt.

I was finally able to run your implementation and more important understood the way it works. Thanks again for your great support in this forum.

However after an amount of time i was able to find another solution which fits more my very special needs after reading the following forum and blog entries and some experiments:

http://www.eclipse.org/forums/index.php/t/169684/
http://www.codetrails.com/blog/osgi-ify-your-tools-jar

What i now do is:

1. Create a dummy plugin with JavaFX (will not make it in the final product)

2. Mark this plugin as optional (it will not be loaded at startup e.g. in the PDE or will be exported in the final product).

3. Add to the classpath: external:$java.home$/lib/jfxswt.jar

Now the plugins will be compiled (because of the dummy plugin) and at runtime the required FXCanvas is available (external classpath) without a OSGI classpath hack (see link at the end) or JavaFX libraries in the ext directory.

I exported my product and JavaFX embedded in SWT runs fine.

Another solution instead of using the external classpath info (programmatic classpath hack) can be found here:

https://www.eclipse.org/forums/index.php/t/796871/






Previous Topic:e(fx)clipse 1.0 feature highlights
Next Topic:JavaFX 8
Goto Forum:
  


Current Time: Sat Apr 25 09:01:51 GMT 2015

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

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