aspose file tools*
The moose likes Beginning Java and the fly likes Difficulty in executing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difficulty in executing" Watch "Difficulty in executing" New topic
Author

Difficulty in executing

renu richard
Ranch Hand

Joined: Oct 06, 2008
Posts: 116
Hi,
I am able to compile Sample.java file. But i could not run that class file. I am getting the below error when trying to execute.
Error
------------
C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\srilanka\WEB-INF\
classes\com\example>java Sample
Exception in thread "main" java.lang.NoClassDefFoundError: Sample (wrong name: c
om/example/Sample)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
4)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
____________________________________________________________________________

Sample.java is inside this package: com/example
I have set "C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\srilanka\WEB-INF\classes\com\example" in the classpath.
And when i am trying to execute it i am getting the above error.

Please help me in solving this. Many thanks!!!


Cheers,
Richard
dee anderson
Greenhorn

Joined: Oct 10, 2008
Posts: 16
try changing to this directory

C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\srilanka\WEB-INF\
classes

and running > java com.example.Sample
renu richard
Ranch Hand

Joined: Oct 06, 2008
Posts: 116
Thanks ande...It Worked!!!
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by renu richard:
Thanks ande...It Worked!!!

But do you understand why this is needed?

The Sample class is part of the package "com.example." Therefore, its fully qualified class name is "com.example.Sample," and this is located in the "classes" directory.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
jQuery in Action, 2nd edition
 
subject: Difficulty in executing