这是我的问题:我正在开发一个应该启动 Javafx 应用程序的 Eclipse 插件。实际上应该很容易,但我仍然遇到问题。这是我的简单 fx-app 的代码示例:
public class UIContainer extends Application{
public static void main(String[] args){
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("First FXML Example");
Pane myPane = (Pane)FXMLLoader.load(getClass().getResource("gui.fxml"));
Scene myScene = new Scene(myPane);
primaryStage.setScene(myScene);
primaryStage.show();
}
现在我想从 Eclipse 插件处理程序运行应用程序,如下所示:
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
//Call the UIContainer here
//do sth. else
return null;
}
根据错误消息,通过 main 或 start-method 调用应用程序实际上没有区别。
org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError: javafx/application/Application
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:243)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:224)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:167)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
...
Caused by: java.lang.ClassNotFoundException: javafx.application.Application cannot be found by XODR-Validator_0.0.1.qualifier
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 60 more
希望您可以跟踪我的问题以找到解决方案。
我的配置:Eclipse Kepler(面向 EE 开发人员的 IDE)JDK1.7.0_40
提前致谢!