aspose file tools*
The moose likes Beginning Java and the fly likes Exception in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception in thread "main" java.lang.NoSuchMethodError: main" Watch "Exception in thread "main" java.lang.NoSuchMethodError: main" New topic
Author

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

Garrett Nickel
Greenhorn

Joined: Jul 08, 2009
Posts: 4

I'm using the Head First: Java 2nd Edition book, and following the instructions for making and testing Movie objects.

my code is :

I am very new to Java, and I have no clue why I am getting "Exception in thread "main" java.lang.NoSuchMethodError: main" even though javac successfully compiles it.

Please help
Michael Angstadt
Ranch Hand

Joined: Jun 17, 2009
Posts: 273

What command are you using to run your program? You should be doing something like:

java MovieTestDrive

You have to use the name of the class that your main method is in when using the "java" command...NOT the name of your source code file.


SCJP 6 || SCWCD 5
Garrett Nickel
Greenhorn

Joined: Jul 08, 2009
Posts: 4
Thanks Michael, it works now!
 
Don't get me started about those stupid light bulbs.
 
subject: Exception in thread "main" java.lang.NoSuchMethodError: main