I am running the following code in eclipse but getting a class not found exception:
         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 error i am getting 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
As mentioned in this thread
Have you listed the
org.eclipse.core.runtimeas a plugin dependency in theManfest.MF?
I think that theIStatusis actually in an Equinox package, but the runtime includes the equinox plugin at runtime.
If you're just running it as a Java application (e.g. by sticking Jars on the classpath) then you'll probably need theorg.eclipse.equinox.core/runtimeor similar.Thanks for your suggestion. The problem was solved by adding
org.eclipse.equinox.commonandorg.eclipse.core.commandsto the Java Build Path property for the project - which I run as an SWT application.
As mentioned by AlBlue in the comment, the Eclipse wiki on JFace confirms:
JFace can be used in standalone SWT+JFace apps, without requiring the Eclipse Runtime or other parts of the Eclipse Platform.
This was made easier to do in 3.2 (2006), with the only prerequisites for JFace being reduced to:
- SWT,
 - the new
 org.eclipse.equinox.commonplug-in,- and
 org.eclipse.core.commandsplug-in.For more details, see Bug 49497.
In 3.3 an optional dependency on the
org.osgi.frameworkpackage was added which is defined in theorg.eclipse.osgi.
If this plug-in is absent JFace will continue to function but without the benefit of internationalization support for its images.
The classpath for compiling isn't necesarily the same as the runtime classpath. There is a launch config (Run->Run...) will shoe you what is there.
Note that the SWT jar is just the API classes - you'll need a per-os binary for the real runtime classes, so that might be missing. If you add the "swt" classpath container then it should do the right thing.
What's the contents of .classpath inbyout current project?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With