Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Using JavaFX 2.0 in an Eclipse view(Creating a view with JavaFX 2.0 graphics in it)
Using JavaFX 2.0 in an Eclipse view [message #781628] Sat, 21 January 2012 21:24 Go to next message
Balint Torok is currently offline Balint TorokFriend
Messages: 7
Registered: July 2009
Junior Member
Hello,

my goal is to create a simple Eclipse view with some graphics in it
(imagine a simple UML diagram) using JavaFx 2.0. I'm using Eclipse 3.6
and Java 1.6.

First I created a plugin project with a view from the Eclipse examples.
Then I modified the SampleViev.createPartControl(Composite parent)
of the generated view class to look like this:

public void createPartControl(Composite parent) {
	         Composite composite = new Composite(parent, SWT.EMBEDDED);
	         FXCanvas fxPanel = new FXCanvas(composite.getShell(), SWT.NONE);  
	         Group group = new Group();
	         Scene scene = new Scene(group);
	         Button button = new Button("JFX Button");
	         group.getChildren().add(button);
	         fxPanel.setScene(scene);
        }


I did manage to set the build path to be able to compile this, but didn't
manage to make it run. I just can't figure out how to set up the runtime
classpath. The assumption is that the user has JavaFX 2.0 installed, so I wouldn't
like to include the JavaFX libs into the plugin, I just want to use what is
already there on the users box.

Could you please advise on how to set up my plugin to use the already
existing JavaFX installation? Or am I going in the wrong direction, and
I should incorporate the JavaFX library into my plugin (if yes then how)?

Thanks.
Re: Using JavaFX 2.0 in an Eclipse view [message #781798 is a reply to message #781628] Sun, 22 January 2012 09:39 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6599
Registered: July 2009
Senior Member
Hi,

Well you need to make yourself familiar with OSGi - modifying the build
path is not an option!

You have 3 possibilities:
a) bundle the fx-libraries with your plugin and adjust your MANIFEST.MF
b) repackage them and add a dependency
c) enhance the OSGi classloader to locate the libs on the filesystem

Now haveing told you those technical things I could simply pointed you
to http://www.efxclipse.org/ which provides you solution c) and
hopefully soon b) as well. It currently has set the lowest version to
3.7.0. Is there a reason it must run on 3.6.0?

Tom

Am 21.01.12 22:24, schrieb Balint Torok:
> Hello,
>
> my goal is to create a simple Eclipse view with some graphics in it
> (imagine a simple UML diagram) using JavaFx 2.0. I'm using Eclipse 3.6
> and Java 1.6.
>
> First I created a plugin project with a view from the Eclipse examples.
> Then I modified the SampleViev.createPartControl(Composite parent)
> of the generated view class to look like this:
>
>
> public void createPartControl(Composite parent) {
> Composite composite = new Composite(parent, SWT.EMBEDDED);
> FXCanvas fxPanel = new FXCanvas(composite.getShell(),
> SWT.NONE); Group group = new Group();
> Scene scene = new Scene(group);
> Button button = new Button("JFX Button");
> group.getChildren().add(button);
> fxPanel.setScene(scene);
> }
>
>
> I did manage to set the build path to be able to compile this, but didn't
> manage to make it run. I just can't figure out how to set up the runtime
> classpath. The assumption is that the user has JavaFX 2.0 installed, so
> I wouldn't
> like to include the JavaFX libs into the plugin, I just want to use what is
> already there on the users box.
>
> Could you please advise on how to set up my plugin to use the already
> existing JavaFX installation? Or am I going in the wrong direction, and
> I should incorporate the JavaFX library into my plugin (if yes then how)?
>
> Thanks.
Re: Using JavaFX 2.0 in an Eclipse view [message #781991 is a reply to message #781798] Sun, 22 January 2012 23:14 Go to previous messageGo to next message
Balint Torok is currently offline Balint TorokFriend
Messages: 7
Registered: July 2009
Junior Member
Hi,

Oh! I have hoped that there is a simple solution like setting up some environment variables or JVM command line parameters.

b) means putting the jfxrt.jar into a plugin (or bundle) and making my plugin dependent on it, right? I tried this, but then I got some java.lang.UnsatisfiedLinkError: Invalid URL for class: bundleresource://497.fwk6586390:2/com/sun/glass/utils/NativeLibLoader.class errors. Did I get these because the OSGI engine didn't find the dll files provided with the JavaFX runtime?
If so, then what do I have to do with these dll files for solution b) ?

c) Out of curiosity, can you please elaborate on how is solution c) realized?

Eclipse 3.6 is a must (for now). It is company policy.

Kind Regards,
Balint
Re: Using JavaFX 2.0 in an Eclipse view [message #782156 is a reply to message #781991] Mon, 23 January 2012 09:22 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6599
Registered: July 2009
Senior Member
Am 23.01.12 00:14, schrieb Balint Torok:
> Hi,
>
> Oh! I have hoped that there is a simple solution like setting up some
> environment variables or JVM command line parameters.
>

Well you could put it on the bootstrap classpath very likely but that
means you need to know where the JavaFX-stuff is installed to. If you
control the complete user system (e.g. an inhouse product) you can use that.

> b) means putting the jfxrt.jar into a plugin (or bundle) and making my
> plugin dependent on it, right? I tried this, but then I got some
> java.lang.UnsatisfiedLinkError: Invalid URL for class:
> bundleresource://497.fwk6586390:2/com/sun/glass/utils/NativeLibLoader.class
> errors. Did I get these because the OSGI engine didn't find the dll
> files provided with the JavaFX runtime?
> If so, then what do I have to do with these dll files for solution b) ?
>

I think you need to rebuild the complete directory structure. JavaFX is
locating its libraries relative to the jar-File. Naturally you need to
ensure that when installing the jar is exploded (so that it gets a
directory once more). But because I haven't tried it my own I can't tell
you exaclty how it could work.

> c) Out of curiosity, can you please elaborate on how is solution c)
> realized?
>

You can have a look at the sources. They are available in my e(fx)clipse
github repo [1]. I've written a bit about the background stuff i used to
make this work [2].

The magic is done by enhancing the Equinox-OSGi-Classloader [3] by using
AdapterHooks and then you need a fake bundle providing the
javafx-packages so that you can add package-imports [4].

I think the sources I provide should work without problems in 3.6 as
well. So you can grab the sources from my git-repo and import them into
your workspace. To make things work then though you need to put the
osgi-sources physically next to it (attention if you import from git the
physical location of the at.bestsolution.efxclipse.runtime.osgi is not
the workspace dir itself).

I'll filed an enhancement for e(fx)clipse to split the features a bit so
that one can install the OSGi-Integration on itsown [5]. The next
release will be in 1 week in conjunction with the next Eclipse 4.2
milestone build.

> Eclipse 3.6 is a must (for now). It is company policy.
> Kind Regards,
> Balint

Tom

[1]https://github.com/tomsontom/e-fx-clipse
[2]http://tomsondev.bestsolution.at/2011/09/23/javafx-2-0-and-osgi-equinox/
[3]https://github.com/tomsontom/e-fx-clipse/tree/master/at.bestsolution.efxclipse.runtime.osgi
[4]https://github.com/tomsontom/e-fx-clipse/tree/master/at.bestsolution.efxclipse.runtime.javafx
[5]http://efxclipse.org/trac/ticket/45
Re: Using JavaFX 2.0 in an Eclipse view [message #782696 is a reply to message #782156] Tue, 24 January 2012 08:45 Go to previous messageGo to next message
Balint Torok is currently offline Balint TorokFriend
Messages: 7
Registered: July 2009
Junior Member
Hi,

thank you Tom, you helped a lot. I glimpsed at your code yesterday but didn't have a lot of time for it.

I think I will try to create a "dummy" plugin that would do nothing more than load the JavaFX libs. Then I can make other plugins depend on this one. Not sure though if it will work, I'm new to OSGI internals.

As for the trac ticket, I'm greatly thankful for that.

Kind regards,
Balint
Re: Using JavaFX 2.0 in an Eclipse view [message #782717 is a reply to message #782696] Tue, 24 January 2012 09:41 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6599
Registered: July 2009
Senior Member
Am 24.01.12 09:45, schrieb Balint Torok:
> Hi,
>
> thank you Tom, you helped a lot. I glimpsed at your code yesterday but
> didn't have a lot of time for it.
> I think I will try to create a "dummy" plugin that would do nothing more
> than load the JavaFX libs. Then I can make other plugins depend on this

Well - the problem you'll run into with that is probably the same you
encountered with copying the libs to your own bundle. Providing a
consumeable OSGi-Bundle for JavaFX is on my todo list as well but the
Adapter-Hook is working nicely at the moment.

> one. Not sure though if it will work, I'm new to OSGI internals.
> As for the trac ticket, I'm greatly thankful for that.
>

The next release is end of this week (most likely Sunday) so I'd suggest
to wait for me to release the stuff and simply consume it.

Tom
Re: Using JavaFX 2.0 in an Eclipse view [message #782735 is a reply to message #782717] Tue, 24 January 2012 10:22 Go to previous messageGo to next message
Balint Torok is currently offline Balint TorokFriend
Messages: 7
Registered: July 2009
Junior Member
Marvelous. I can hardly wait for it Smile

Thanks Tom

Kind Regards
Balint
Re: Using JavaFX 2.0 in an Eclipse view [message #782828 is a reply to message #782735] Tue, 24 January 2012 14:33 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6599
Registered: July 2009
Senior Member
Make sure you subscribe to my blog or follow me on twitter (@tomsontom)
so that you get informed about the release in case I forget to follow up
here.

Tom

Am 24.01.12 11:22, schrieb Balint Torok:
> Marvelous. I can hardly wait for it :)
>
> Thanks Tom
>
> Kind Regards Balint
Re: Using JavaFX 2.0 in an Eclipse view [message #788126 is a reply to message #782735] Wed, 01 February 2012 11:30 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6599
Registered: July 2009
Senior Member
I've released 0.0.12 but it looks like its not working on 3.6 because I
need to get access to the classloader of the SWT-Bundle to use the
SWT-Integration and this API is new to 3.7.

One could get it to work probably using the Swing-AWT-Bridge because
there one does not need to the SWT-Bundle-Classloader.

If you need a solution soon I can only offer you to contract me for some
hours (~ 4 hours) to implement it and release an intermediate update-site.

Tom

Am 24.01.12 11:22, schrieb Balint Torok:
> Marvelous. I can hardly wait for it :)
>
> Thanks Tom
>
> Kind Regards Balint
Previous Topic:Install Issues
Next Topic:eclipse formatter and comments (/* */)
Goto Forum:
  


Current Time: Thu Jun 24 19:50:46 GMT 2021

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

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

Back to the top