Eclipse 找不到 JFace 中的主类?

发布于 2024-12-19 12:05:58 字数 1500 浏览 1 评论 0原文

我正在阅读 Manning Press 出版的《SWT/JFace IN ACTION》一书。

当我添加 JFace 时,Eclipse 由于某种原因无法找到主类,尽管它显然存在。

这是代码

package com.swtjface.ChTwo;

import org.eclipse.jface.window.*;
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;

public class HelloSWT_JFace extends ApplicationWindow{

/**
 * @param args
 */
public HelloSWT_JFace(){
    super(null);
}
protected Control createContents(Composite parent){
    Text helloText = new Text(parent, SWT.CENTER);
    helloText.setText("Hello SWT and JFace!");
    parent.pack();
    return parent;
}
public static void main(String[] args) {
    // TODO Auto-generated method stub
    HelloSWT_JFace awin = new HelloSWT_JFace();
    awin.setBlockOnOpen(true);
    awin.open();
    Display.getCurrent().dispose();
}

 }

我从 Eclipse 收到的拒绝消息是...

Could not find the main class: com.swtjface.ChTwo.HelloSWT_JFace.
Program will exit.

这是例外...

java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IProgressMonitor
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.IProgressMonitor
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"

I'm working though a book SWT/JFace IN ACTION by Manning Press.

When I added JFace, Eclipse for some reason could not find the main class though it is plainly present.

Here is the code

package com.swtjface.ChTwo;

import org.eclipse.jface.window.*;
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;

public class HelloSWT_JFace extends ApplicationWindow{

/**
 * @param args
 */
public HelloSWT_JFace(){
    super(null);
}
protected Control createContents(Composite parent){
    Text helloText = new Text(parent, SWT.CENTER);
    helloText.setText("Hello SWT and JFace!");
    parent.pack();
    return parent;
}
public static void main(String[] args) {
    // TODO Auto-generated method stub
    HelloSWT_JFace awin = new HelloSWT_JFace();
    awin.setBlockOnOpen(true);
    awin.open();
    Display.getCurrent().dispose();
}

 }

The reject message I get from Eclipse is...

Could not find the main class: com.swtjface.ChTwo.HelloSWT_JFace.
Program will exit.

Here is the exception...

java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IProgressMonitor
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.IProgressMonitor
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏天碎花小短裙 2024-12-26 12:05:58

您至少还需要 2 个 jar 才能使用 JFace:

  • org.eclipse.equinox.common
  • org.eclipse.core.commands

请参阅 在 Eclipse 平台之外使用 JFace 了解更多详细信息。

You need at least 2 more jars to use JFace:

  • org.eclipse.equinox.common
  • org.eclipse.core.commands

See Using JFace outside the Eclipse platform for more details.

み青杉依旧 2024-12-26 12:05:58

您需要为“org.eclipse.core.runtime.IProgressMonitor 类”添加 jar 文件

检查 此链接

You need to add jar file for "org.eclipse.core.runtime.IProgressMonitor class"

Check this link.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文