Hi Cristiano, For running program which is inside a package, full classname with package heirarchy is required. For your case, it will be foodpackage.fruitpackage.FoodMain. This needs to run from the directory where foodpackage directory is located or if its inside a jar, jar should be included in the classpath like:
java -cp <jar-name> foodpackage.fruitpackage.FoodMain Aditya On Fri, Feb 5, 2010 at 4:19 PM, Cristiano Carvalho <[email protected]> wrote: > Hi guys, I'm using Linux Ubuntu... the Java Classpath Homework brings only > samples for Windows... Can any one help me with the command line for run the > FoodMain please!!!! I Have tested the code and it works but when I try form > command line... gives me an error... > > Exception in thread "main" java.lang.NoClassDefFoundError: FoodMain (wrong > name: foodpackage/fruitpackage/FoodMain) > at java.lang.ClassLoader.defineClass1(Native Method) > at java.lang.ClassLoader.defineClass(ClassLoader.java:632) > at > java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) > at java.net.URLClassLoader.defineClass(URLClassLoader.java:277) > at java.net.URLClassLoader.access$000(URLClassLoader.java:73) > at java.net.URLClassLoader$1.run(URLClassLoader.java:212) > at java.security.AccessController.doPrivileged(Native Method) > at java.net.URLClassLoader.findClass(URLClassLoader.java:205) > at java.lang.ClassLoader.loadClass(ClassLoader.java:319) > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) > at java.lang.ClassLoader.loadClass(ClassLoader.java:264) > at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332) > Could not find the main class: FoodMain. Program will exit. > > > -- > Cristiano Carvalho > > Jesus Ă© bom! AlelĂșia! > > -- > To post to this group, send email to > [email protected] > To unsubscribe from this group, send email to > [email protected]<javaprogrammingwithpassion%[email protected]> > For more options, visit this group at > http://groups.google.com/group/javaprogrammingwithpassion?hl=en -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en
