How to use JavaFX 2 SDK in Eclipse?

2019-01-08 20:05发布

I have installed JavaFX 2.0 SDK and now I would like to do an JavaFX application with Eclipse. But how can I use the javafx.* classes in Eclipse?

The official JavaFX Eclipse plugin seem to be for JavaFx 1.2 and outdated.

When I try to install e(fx)clipse plugin, I get this error:

Cannot complete the install because one or more required items could not be found.
  Software being installed: efxclipse 0.0.8.201111131640 (at.bestsolution.efxclipse.feature.feature.group 0.0.8.201111131640)
  Missing requirement: Eclipse DI integration for JavaFX 0.0.8.201111131640 (at.bestsolution.efxclipse.runtime.di 0.0.8.201111131640) requires 'bundle org.eclipse.e4.core.contexts 0.9.0' but it could not be found
  Cannot satisfy dependency:
    From: efxclipse 0.0.8.201111131640 (at.bestsolution.efxclipse.feature.feature.group 0.0.8.201111131640)
    To: at.bestsolution.efxclipse.runtime.feature.feature.group [0.0.8.201111131640]
  Cannot satisfy dependency:
    From: FX Runtime 0.0.8.201111131640 (at.bestsolution.efxclipse.runtime.feature.feature.group 0.0.8.201111131640)
    To: at.bestsolution.efxclipse.runtime.di [0.0.8.201111131640]

8条回答
Emotional °昔
2楼-- · 2019-01-08 20:44

To install the e(fx)clipse tooling into your already existing Eclipse you have to add an Update site.

There's no released yet available so you need to add the nightly update-site http://download.eclipse.org/efxclipse/updates-nightly/site

查看更多
你好瞎i
3楼-- · 2019-01-08 20:45

As an aside, it says it won't install the FX plugin because you are missing org.eclipse.e4.core.contexts bundle. Were you trying to install it into Eclipse Indigo, or 3.8? Or did you follow the instructions on the website and download eclipse 4.2 before you started?

查看更多
爷的心禁止访问
4楼-- · 2019-01-08 20:46

I installed Eclipse Neon.1 (4.6.1) Then Help => Eclipse Marketplace On find specify "javaFX" and install "e(fx)clise 2.4.0"

查看更多
在下西门庆
5楼-- · 2019-01-08 20:55

If you don't mind working with java 8, you won't have to jump through any hoola hoops. Just set that as your default jre and javafx imports work out of the box.

查看更多
Juvenile、少年°
6楼-- · 2019-01-08 21:02

There are two options:

1) EDIT: Since 7u35 (or smth near it) JavaFX was included into base JDK classpath so you can use JavaFX classes right away.

Just set up your projects to use fx libs:

JavaFX 2.0 API is pure Java. So you can create a new Java project and add sdk-path/rt/lib/jfxrt.jar to libraries to use JavaFX in that project.

For cobundled builds in JDK7 path would be next jdk-path/jre/lib/jfxrt.jar

2) Use e(fx)clipse plugin: http://www.eclipse.org/efxclipse/index.html

查看更多
放荡不羁爱自由
7楼-- · 2019-01-08 21:05

You can use e(fx)clipse! You can find it here: http://www.eclipse.org/efxclipse/index.html

After download you must to configure the IDE with your JavaFX SDK(must be installed).

All you need to do is to open Window > Preferences > JavaFX and configure the location of your JavaFX-SDK.

You ussualy have it in Program Files > Oracle.

Hope this will help you!

查看更多
登录 后发表回答