?
Solved

Exception in thread "main" java.lang.NoClassDefFoundError

Posted on 2006-04-12
4
Medium Priority
?
354 Views
Last Modified: 2012-05-05
I receive the following error trying to run the class Music5.class ( it does have a main entry, it is in the C:\java\code\c08\music5 directory)
--------------------------------------------------------------------------------------------
C:\java\code\c08\music5>java -classpath C:\java\code Music5.class
Exception in thread "main" java.lang.NoClassDefFoundError: Music5/class

C:\java\code\c08\music5>java Music5
Exception in thread "main" java.lang.NoClassDefFoundError: Music5 (wrong name: c
08/music5/Music5)
        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)

C:\java\code\c08\music5>
-----------------------------------------------------------------------

Any thoughts?
0
Comment
Question by:kellyputty
  • 3
4 Comments
 
LVL 14

Expert Comment

by:hoomanv
ID: 16439372
java -classpath C:\java\code Music5 // without .class
0
 
LVL 14

Accepted Solution

by:
hoomanv earned 2000 total points
ID: 16439380
is Music5 in a package ?
0
 

Author Comment

by:kellyputty
ID: 16439455
Thank you.
It was:
java -classpath C:\java\code c08.music5.Music5

Even if you are in the appropriate directory you need to specify the entire package name?
0
 
LVL 14

Expert Comment

by:hoomanv
ID: 16439482
yes
it is correct too, no need for classpath if you are already in C:\java\code
C:\java\code> java c08.music5.Music5

thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month14 days, 7 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question