HorstBrack
HorstBrack

Reputation: 21

Usage of jfxrt.jar in Eclipse Kepler (SR2) Plugin

i'm, playing with an Eclipse 4 Application and Java 8, currently in Eclipse Kepler SR2. There are various pitfalls which i don't understand, therefore i'm looking for your help:

When i create a new plug-in in Java 8 (JDK) environment, the jfxrt.jar is listed in the JRE System Libraries in my project.

When i try to access a jfxrt class, i'll get an error (Discouraged Access). I tried to solve the error adjusting the build path by creating an Access Rule (*/) to my JRE System Library. Sometimes it worked, somestimes i had to adjust the Compiler Settings for Discouraged Access to warning too.

Afterwards, i could access the classes and compile them, but when i try to run (debug), the classes are still NOT visible to the plugin:

java.version=1.8.0
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=de_DE
Framework arguments:  -product de.fsch.ibot.app.product -clearPersistedState
Command-line arguments:  ... -consoleLog -clearPersistedState

!ENTRY org.eclipse.osgi 4 0 2014-04-03 09:15:12.790
!MESSAGE Application error
!STACK 1
.
.
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application

Any suggestions for me ?

Upvotes: 1

Views: 1121

Answers (2)

stolsvik
stolsvik

Reputation: 5341

For the restricted access, do this: Go to project properties, java build path, libraries.

  • Remove the "JRE System Library [java8]" thing
  • .. and then add it again using "Add Library"-button -> JRE System Library -> Workspace default (if that is set to Java 8 on your workspace, if not, pick another option here).

Got this from this SO answer.

Annoyingly, this worked for me!

Upvotes: 0

tomsontom
tomsontom

Reputation: 5897

  1. restricted access - yes the reason is that JavaFX is on the extension classpath hence it is treated as an implementation detail of the VM by Eclipse
  2. Runtime problem is because JavaFX packages ARE NOT part of any EE hence you can not find them in an OSGi-Env
  3. It does not make sense to use launch a JavaFX-Application inside an SWT-IDE plugin there you use an FXCanvas which will lead to your next problem because this is not on ANY classpath at all because it depends on SWT (you find it in your jre/lib/jfxswt.jar)

My suggestion is: Do yourself some a favor and install e(fx)clipse e.g. you can get an all in one download from http://efxclipse.bestsolution.at/install.html or use the update-site from http://www.efxclipse.org/install.html and follow https://wiki.eclipse.org/Efxclipse/Tutorials/Tutorial2 if you want to go pure fx (no swt involved) then https://wiki.eclipse.org/Efxclipse/Tutorials/Tutorial3 and https://wiki.eclipse.org/Efxclipse/Tutorials/Tutorial4 are probably interesting to you

Upvotes: 1

Related Questions