This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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: 63206

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

[Asking smart questions] [Bear's FrontMan] [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: 3899

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: This code tells me i don't have a main()
It's not a secret anymore!