permaculture playing cards
The moose likes Beginning Java and the fly likes This code tells me i don't have a main() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "This code tells me i don Watch "This code tells me i don New topic

This code tells me i don't have a main()

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266

java.lang.NoSuchMethodError: main
Exception in thread "main"
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

The public class doesn't have a main method, so why is this a surprise?

[Asking smart questions] [About Bear] [Books by Bear]
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 632

You must have to write main method in public class and save file name as name of public class.

Life is easy because we write the source code.....
Vijitha Kumara

Joined: Mar 24, 2008
Posts: 3902

Or you should run the Test5 not the Test4 class.

[How to ask questions] [Twitter]
Thangaraj Selvamani
Ranch Hand

Joined: Sep 20, 2008
Posts: 61
Make Test5 class as public and remove public from Test4 class. save the filename in
Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 384

the filename corresponds to the name of the public class in the java file ... and only one class can be public ...
I agree. Here's the link:
subject: This code tells me i don't have a main()
It's not a secret anymore!