Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is the error thats troubling me :

MSIL
C:\Documents and Settings\xxxx\Desktop\Java Files New>javac MSWord.java

C:\Documents and Settings\xxxx\Desktop\Java Files New>java MSWord
Exception in thread "main" java.lang.NoClassDefFoundError: MSWord (wrong name: o
rg/jinterop/dcom/test/MSWord)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(Unknown Source)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$000(Unknown Source)
        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)
Could not find the main class: MSWord.  Program will exit.



Environment Variables:

JAVA_HOME C:\glassfishv3\jdk\

CLASSPATH .;C:\Program Files\QuickTime\QTSystem\QTJava.zip;C:\Documents and Settings\xxxx\Desktop\j-Interop\lib\j-interop.jar;C:\Documents and Settings\xxxx\Desktop\j-Interop\lib\jcifs-1.2.19.jar;C:\Documents and Settings\xxxx\Desktop\j-Interop\lib\j-interopdeps.jar;C:\Documents and Settings\xxxx\Desktop\j-Interop\lib\progIdVsClsidDB.properties;C:\glassfishv3\jdk\bin;C:\Documents and Settings\xxxx\Desktop\Java Files New;C:\glassfishv3\jdk\lib;

Path %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;C:\gwt-2.1.0;%ANT_HOME%\bin;C:\Program Files\Java\jre6\bin;C:\glassfishv3\jdk\bin;

Details:
Installed Java(TM) 6 update 22
Java(TM) 6 update 5
C:\Program Files\Java\jre1.6.0_05
C:\Program Files\Java\jre6.0
C:\glassfishv3\jdk

Tools.jar is present in all the lib and bin folders of the above locations.

Tried all these:
http://www.tech-recipes.com/rx/826/java-exception-in-thread-main-javalangnoclassdeffounderror/[^]

http://www.jguru.com/faq/view.jsp?EID=455768&page=1[^]

Nothing has resolved my issue, i am new to java and very confused on whats happening!! I knew the error is with classpath but i have tried all possible combinations.

Any suggestions or advices!! Please let me know if you need any more info!!
Posted

1 solution

Couple notes:

* Have you restarted your command line editor (cmd) after changing the environment variables.

* Is your MSWord class defined inside a package. If so, the package name also should be noted when calling the class. Like so:
C:\....\Java Files New>java mypackage.MSWord

* I'd suggest to put your workspace in a shorter path like C:/myjava

* And finally try to specify classpath in the command line like so:
C:\myjava>java -classpath C:\myjava mypackage.MSWord


Hope this will help.
 
Share this answer
 
Comments
amarasat 2-Dec-10 14:03pm    
Thanks alot, this one has helped finally, u helped a lot!!

C:\....\Java Files New>java mypackage.MSWord, i was able to execute it!!
amarasat 2-Dec-10 15:12pm    
Hello Arman,

Can you also help me in getting this to execute in eclipse:

I am using Eclipse SDK 3.6, i just opened the file from my C:\Documents and Settings\xxxx\Desktop\Java Files New\ location.

When i run the file using Ant Build i get the following error message:

java.lang.NullPointerException
at org.eclipse.ant.internal.ui.AntUtil.isKnownAntFile(AntUtil.java:593)
at org.eclipse.ant.internal.ui.launchConfigurations.AntLaunchShortcut.launch(AntLaunchShortcut.java:465)
at org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension.launch(LaunchShortcutExtension.java:424)
at org.eclipse.debug.internal.ui.contextlaunching.ContextRunner.launchShortcut(ContextRunner.java:217)
at org.eclipse.debug.internal.ui.contextlaunching.ContextRunner.showShortcutSelectionDialog(ContextRunner.java:286)
at org.eclipse.debug.internal.ui.contextlaunching.ContextRunner.selectAndLaunch(ContextRunner.java:140)
at org.eclipse.debug.internal.ui.contextlaunching.ContextRunner.launch(ContextRunner.java:82)
at org.eclipse.debug.ui.actions.AbstractLaunchToolbarAction.run(AbstractLaunchToolbarAction.java:79)
at org.eclipse.debug.ui.actions.AbstractLaunchHistoryAction.runWithEvent(AbstractLaunchHistoryAction.java:404)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:241)
at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:452)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900