不能在eclipse中使用JFace和SWT而不创建插件 [英] Can't use JFace and SWT in eclipse without creating plugin

查看:212
本文介绍了不能在eclipse中使用JFace和SWT而不创建插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

免责声明

这是.NET GUI试图围绕JAVA工作的经典案例。

this is the classic case of .NET GUI trying to work his way around JAVA stuff.

问题描述:

我正在使用JFace和SWT构建一个非常简单的GUI代码很简单(有很多教程),它不是那么直截了当,我似乎无法让JFace和SWT在一个插件项目之外工作。

I am trying to build a very simple GUI with JFace and SWT - the code is straightforward (there's plenty tutorials), what it's not so straightforward is that I can't seem to get JFace and SWT to work outside a plugin project.

我会期望能够在我的项目中使用JFace和SWT没有麻烦,因为我在我的CLASSPATH(从我的电脑 - >属性 - >高级 - >环境变量)中放入C:/ eclipse 3.5 / plugins)和所有我可以在我的PATH(本地用户和全局PATH中确定)中找到swt - *。dll作为这篇文章在安装SWT和JFace框中指出。

I would expect to be able to use JFace and SWT in my project no hassle, since I put "C:/eclipse 3.5/plugins" in my CLASSPATH (from my computer --> properties --> advanced --> environment variables) and all the swt-*.dll I could find in my PATH (both local user and global PATHs, to be sure) as this article indicates in the "Installing SWT and JFace" box.

问题是我无法从日食中导入任何内容.org除非我说nce直接从构建路径的jar - >库 - >添加外部jar(为了它构建我必须添加以下jar: org.eclipse.swt.win32.win32.x86_3.5.1.v3555a。 jar org.eclipse.jface_3.5.1.M20090826-0800.jar )。一旦我这样做,它构建良好,但是当我运行它作为Java应用程序我得到以下错误(我应该如何运行AS 其他?):

Problem is I can't import anything from eclipse.org unless I reference directly the jars from buildpath --> libraries --> add external jars (in order for it to build I have to add the following jars: org.eclipse.swt.win32.win32.x86_3.5.1.v3555a.jar, org.eclipse.jface_3.5.1.M20090826-0800.jar). Once I do that it builds fine but then when I run it as "Java Application" I get the following error (should I RUN AS something else?):

Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IProgressMonitor
    at demo.ui.test.EntryPoint.main(EntryPoint.java:18)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.IProgressMonitor
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    ... 1 more

我试图调试这个和基本的一旦它尝试实例化 ApplicationWindow 类(org.eclipse.jface.window.ApplicationWindow),它就会被抛出。尝试重现错误,我发表了我的所有代码,并将其替换为主要的以下内容,并在第一行引用了与上述相同的错误:

I tried to debug this and basically it is thrown as soon as it tries to instantiate the ApplicationWindow class (org.eclipse.jface.window.ApplicationWindow). Trying to reproduce the error, I commented out all my code and replaced it with the following in my main and it throws he same error as above on the first line:

ApplicationWindow w = new ApplicationWindow(null); //<-- error on this line
w.setBlockOnOpen(true);
w.open();
Display.getCurrent().dispose();

问题:

问题1 :如何解决上述错误(我想了解发生了什么事情),并得到可怕的事情?

Question 1: how can I fix the error above (I'd like to understand what's going on) and get the damn thing to run?

问题2 :为什么罐子对我的项目不可见,如何制作?

Question 2: why the jars are not visible to my project and how to make them?

由于我对Java和eclipse的熟悉程度不大,所以微不足道。任何帮助高度赞赏!

I am probably missing something very trivial due to my lack of familiarity with Java and eclipse. Any help highly appreciated!

编辑:似乎有人遇到同样的问题 - > http://www.eclipsezone.com/eclipse/forums/t60528.html - 不太清楚他们如何解决它,帮助赞赏

EDIT: seems like someone else had the same problem --> http://www.eclipsezone.com/eclipse/forums/t60528.html - not too clear how they solved it though, assistance appreciated

推荐答案

IProgressMonitor 接口在您使用的两个jar中不可用。您还需要在您的类路径中放置 org.eclipse.equinox.common 插件。 IProgressMonitor 可以在没有整个eclipse环境运行的情况下使用。

IProgressMonitor interface is not available in those two jars you use. You also need to put org.eclipse.equinox.common plugin on your classpath. IProgressMonitor can be used without whole eclipse environment running.

(这是您引用的文章的解决方案原来以为IProgressMonitor是在org.eclipse.core.runtime插件,但它已被移动到org.eclipse.equinox.common,如 bug#122935

(This is solution from the article you refer to. I originally thought that IProgressMonitor is in org.eclipse.core.runtime plugin, but it has been moved to org.eclipse.equinox.common as described in bug #122935)

这篇关于不能在eclipse中使用JFace和SWT而不创建插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆