Getting class not detected Exception on start in eclipse

I run the following code in eclipse, but get a class exception not found:

import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class DialogClass { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("TEst"); Shell frame = new Shell(SWT.SHELL_TRIM); PublishGenericArtefactDialog publishGenericArtefactDialog = new PublishGenericArtefactDialog(frame); publishGenericArtefactDialog.setTitle("Test"); if (publishGenericArtefactDialog.open() == Window.CANCEL){ try { throw new Exception("Cancelled"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } 

and the error I get is

  TEst Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IStatus at DialogClass.main(DialogClass.java:19) Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.IStatus 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) at java.lang.ClassLoader.loadClassInternal(Unknown Source) ... 1 more 

need help

+7
java eclipse
source share
4 answers

As mentioned in this thread

Did you specify org.eclipse.core.runtime as a plugin dependency in Manfest.MF ?
I think IStatus is actually in the Equinox package, but the runtime includes the equinox plugin at runtime.
If you just run it as a Java application (for example, sticking Jars on the classpath), you probably need org.eclipse.equinox.core/runtime or the like.

Thank you for your offer. The problem was resolved by adding org.eclipse.equinox.common and org.eclipse.core.commands in the Java Path Path property for the project that I run as a SWT application.

As mentioned in an AlBlue comment, the Eclipse wiki on JFace confirms:

JFace can be used in standalone SWT + JFace applications without requiring Runtime Eclipse or other parts of the Eclipse platform.
This was easier to do in 3.2 (2006), with the only prerequisites for reducing JFace to:

  • SWT ,
  • new org.eclipse.equinox.common plugin,
  • and org.eclipse.core.commands .

See Error 49497 for more details.

3.3 adds an additional dependency on the org.osgi.framework package, which is defined in org.eclipse.osgi .
If this plugin is missing, JFace will continue to function, but without the support of internationalizing its images.

+10
source share

The classpath for compilation is not necessarily the same as the classpath for the runtime. There is a launch version (Run-> Run ...) that will teach you what it is.

Please note that SWT-jar are just API classes. For real runtime classes, you will need the per-os binary, so it may be missing. If you add a container of class "swt", then it should do the right thing.

What is the contents of .classpath in the current project?

+2
source share

When you launch an exported product, if you see something like

 org.osgi.framework.BundleException: The activator org.eclipse.ui.internal.WorkbenchPlugin for bundle org.eclipse.ui.workbench is invalid ... Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.SWTError 

It can be fixed with:

  • Open the product configuration editor in your product file
  • Click on the "Launch" tab.
  • Delete the "Program Arguments" and "VM Arguments" fields.
  • Product Re-Export
0
source share

Have you imported something for this?

 PublishGenericArtefactDialog publishGenericArtefactDialog = new PublishGenericArtefactDialog(frame); 
-one
source share

All Articles