带有 java.lang.ClassNotFoundException 的 SWT FileDialog
SWT FileDialog with java.lang.ClassNotFoundException
在我的 java 程序中,我试图创建一个 FileDialog 来保存文件。但是我收到了这个错误。
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
这是我创建对话框的方式:
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;
}
找了几天还是没搞清楚。有人可以帮忙吗?
编辑:
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 只是一些其他捆绑包的名称,但我无法在此处显示。
您需要将 org.eclipse.swt
添加到您插件的 MANIFEST.MF 中的 Require-Bundle
列表中。
您可以在 plugin.xml 编辑器的 'Dependencies' 选项卡中执行此操作 'Required Plug-ins' table。
在我的 java 程序中,我试图创建一个 FileDialog 来保存文件。但是我收到了这个错误。
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
这是我创建对话框的方式:
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;
}
找了几天还是没搞清楚。有人可以帮忙吗?
编辑:
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 只是一些其他捆绑包的名称,但我无法在此处显示。
您需要将 org.eclipse.swt
添加到您插件的 MANIFEST.MF 中的 Require-Bundle
列表中。
您可以在 plugin.xml 编辑器的 'Dependencies' 选项卡中执行此操作 'Required Plug-ins' table。