• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

This must be embarrassingly simple

 
Dennis Noren
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With the following code:



I get the compile error:
'cannot resolve symbol' on line
Shape shape1 = new Shape(Color.green, shape1Name);

If I comment out that line, the code compiles successfully but I get the runtime error:

Exception in thread "main" java.lang.NoSuchMethodError: main

What is going on?
 
Liam Tiarnach
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm...

Let's see...



okay there is where you attempt to instantiate you Shape class, passing the arguement Color.green and shape1Name...
but...

here is your constructor for Shape that take no arguments... So the compiler give you an error...
to fix this you will have to create a constructor that does take Color and StringBuffer as arguements...
[code] Shape (Color colorArg ,StringBuffer stringBufferArg){
// do stuff
}[code]
 
Dennis Noren
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks -- that fixed it for the compile error. For the runtime error, it was that I needed to name the file the same as the class that had main in it.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic