This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.NoSuchMethodError

 
Siva kandasamy
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I have a simple code, causing run time exception, not sure why ?
Placed below, is the source code and error message:

Error Message:
=============
% javac Shapes.java
% java Shapes
Exception in thread "main" java.lang.NoSuchMethodError: Shape: method <init>()V not found
at Square.<init>(Shapes.java:4)
at Shapes.main(Shapes.java:9)
 
Rocky Summers
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need to put a default constructor for your Shapes.java
 
Rocky Summers
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh yeah, you need to name your class the same name as your file. eg: Shape.java, you MUST name your class Shape...
 
Siva kandasamy
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to you all.
I figured out, this is due to the collision.
Now it works fine.
thanks
siva
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic