[英]SWT FileDialog with java.lang.ClassNotFoundException
In my java program I'm trying to create a FileDialog to save files. 在我的Java程序中,我试图创建一个FileDialog来保存文件。 But I'm getting this error.
但是我遇到了这个错误。
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.FileDialog cannot be found by xxx.xxx.maintenance_1.0.0
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:423)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:336)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:328)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 24 more
This is how I create the dialog: 这是我创建对话框的方式:
public DownloadLogFilesDialog(Shell parent, int style) {
super(parent, style);
shell = new Shell(getParent(), SWT.APPLICATION_MODAL);
fileDialog = new FileDialog(shell, style); // error at this line
}
@SuppressWarnings("javadoc")
public Object open() {
shell.setSize(width, height);
Rectangle parentBounds = getParent().getBounds();
shell.setLocation(
parentBounds.x + (parentBounds.width - width) / 2,
parentBounds.y + (parentBounds.height - height) / 2);
fileDialog.setText("Download Log Files"); //$NON-NLS-1$
fileDialog.setFilterPath(System.getProperty("user.home")); //$NON-NLS-1$
Object result = fileDialog.open();
shell.dispose();
return result;
}
After searching for a few days I still have no idea about this. 搜索几天后,我仍然对此一无所知。 Anyone can help?
有人可以帮忙吗?
EDIT: 编辑:
MANIFEST.MF MANIFEST.MF
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: System
Bundle-SymbolicName: xxx.xxx.maintenance;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: com.xxx.xxx.xxx.ui.maintenance.Activator
Bundle-Vendor: ClareControls
Require-Bundle:
org.eclipse.core.runtime;bundle-version="3.10.0",
org.eclipse.rap.ui;resolution:=optional;visibility:=reexport,
org.eclipse.rap.ui.forms;resolution:=optional;visibility:=reexport,
xxx.xxx.common,
xxx.xxx.db
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Import-Package:
com.xxx.xxx.xxx.db.entities;version="1.0.0",
com.xxx.xxx.xxx.ui.common,
com.xxx.xxx.xxx.ui.common.editors,
com.xxx.xxx.xxx.ui.common.events,
com.xxx.xxx.xxx.ui.components,
com.xxx.xxx.xxx.ui.db,
com.xxx.xxx.xxx.ui.projects,
com.xxx.xxx.xxx.ui.projects.editors,
com.xxx.xxx.xxx.ui.system.dialogs,
com.xxx.xxx.xxx.ui.system.views,
com.xxx.xxx.xxx.util,
javax.persistence;version="[2.0.1,3.0.0)",
org.apache.commons.io;version="2.0.0",
org.json
X-Export-Package: com.xxx.xxx.xxx.ui.maintenance
xxx is just name of some other bundles but I can't show here. xxx只是其他捆绑软件的名称,但我无法在此处显示。
You need to add org.eclipse.swt
to the Require-Bundle
list in the MANIFEST.MF for your plugin. 您需要将
org.eclipse.swt
添加到MANIFEST.MF中用于插件的Require-Bundle
列表中。
You can do this in the plugin.xml editor on the 'Dependencies' tab in the 'Required Plug-ins' table. 您可以在“必需的插件”表中“依赖关系”选项卡上的plugin.xml编辑器中执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.