Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes NoClassDefFound. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NoClassDefFound." Watch "NoClassDefFound." New topic
Author

NoClassDefFound.

Ravi Mutyala
Greenhorn

Joined: Oct 30, 2003
Posts: 3
Hi,
I have a class, in whose main() the same class is instantiated. like
class xyz{
public static void main(String[] args)
{
xyz a = new xyz();
}
}
I'm able to compile this file, there is a NoClassDefFound. If I use another class abc in whose main, i instantiate xyz, it it working fine.
what could be the problem? The classpath seems ok, as it is working in the second case.
Thanks in advance.
Ravi.
John Twenty
Greenhorn

Joined: Oct 17, 2003
Posts: 3
You did forget to implement a default constructor!
Greetz
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

Java gives you a default ctor, if you don't make one. (I think.)
Is the file the same name as the class?


Please ignore post, I have no idea what I am talking about.
Ravi Mutyala
Greenhorn

Joined: Oct 30, 2003
Posts: 3
I did infact put a constructor. While giving the example of this situation, I skipped the constructor.
Has anyone else faced this strange problem?
Ravi Mutyala
Greenhorn

Joined: Oct 30, 2003
Posts: 3
Originally posted by William Barnes:
Java gives you a default ctor, if you don't make one. (I think.)
Is the file the same name as the class?

Yep. The class name and file name are same. And I'm able to instantiate and use this class in another class. The problem is only when I try to instantiate the same class in the main().
John Twenty
Greenhorn

Joined: Oct 17, 2003
Posts: 3
When i start the main method it works! strange!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NoClassDefFound.
 
Similar Threads
NoClassDefFound Exception
NoClassDefFound-wrong name
NoClassDefFound error
NoClassDefFound
why NoClassDefFound?