aspose file tools*
The moose likes Beginning Java and the fly likes NoSuchMethod:main error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NoSuchMethod:main error" Watch "NoSuchMethod:main error" New topic
Author

NoSuchMethod:main error

Sami Devine
Ranch Hand

Joined: Jan 30, 2011
Posts: 44
I found the following eg in K & B SCJP 6



I have saved the file as Zoo.java. After javac Zoo.java both Zoo.class and Moo.class are created.
But for java Moo and java Zoo, I get "Exception in thread "main":NoSuchMethodError:main"
Does this indicate that I need to use the main method in Moo?
When is the main method not needed.
Thanks
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

The main method is needed if you want to execute your program. The Moo does not have it, so you can't do "java Moo". In fact, none of your classes have a main method, so you're not expected to execute any of them. Just to compile them.


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NoSuchMethod:main error
 
Similar Threads
Access Modifiers
Not compiling
Inheritance
Method is static, yet I get compiler error saying it cannot be accessed from static context