File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
RabbitMQ in Depth
this week in the
Joined: Feb 10, 2009
May 04, 2009 04:04:41
Getting this error while running
. Please suggest. I have defined required things in the classpath
C:\MyProject\classes\com\wickedlysmart>java CmdArgs Exception in thread "main" java.lang.NoClassDefFoundError: CmdArgs (wrong name: com/wickedlysmart/CmdArgs) at java.lang.ClassLoader.defineClass1(Native Method) 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) at java.lang.ClassLoader.loadClassInternal(Unknown Source) Could not find the main class: CmdArgs. Program will exit.
Joined: Mar 22, 2005
May 04, 2009 04:10:12
You always need to give the fully qualified classname: "java com.wickedlysmart.CmdArgs". This should work assuming that the "classes" directory is in the classpath.
Joined: Mar 28, 2009
May 04, 2009 16:52:03
From what I can see, you are currently in the same directory as your .class file. Instead of running the class from here, you should run it from the /classes directory, like this:
That is, assuming that the class includes a package statement at the beginning of the file:
I agree. Here's the link:
Class path magic
Issues with cmd java command
Why oh why do I even Try??
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015