jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes This must be embarrassingly simple Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "This must be embarrassingly simple" Watch "This must be embarrassingly simple" New topic

This must be embarrassingly simple

Dennis Noren

Joined: Jan 07, 2005
Posts: 15
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?

Java novice, J2SE 1.4.2<br />Some C, some OOA/OOD
Liam Tiarnach
Ranch Hand

Joined: Aug 06, 2004
Posts: 51

Let's see...

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

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

- Liam...<br />- ' He who never sleeps... '
Dennis Noren

Joined: Jan 07, 2005
Posts: 15
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.
subject: This must be embarrassingly simple
Similar Threads
quick beginners question
Calling methods using dynamic binding
Why does this get a run-time error?
A Paint Application with Combo Boxes and Buttons
Rectangle error