This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NoClassDefFound.  RSS feed

 
Ravi Mutyala
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You did forget to implement a default constructor!
Greetz
 
William Barnes
Ranch Hand
Posts: 1046
2
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java gives you a default ctor, if you don't make one. (I think.)
Is the file the same name as the class?
 
Ravi Mutyala
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i start the main method it works! strange!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!