aspose file tools*
The moose likes Beginning Java and the fly likes public static int main(String args[]) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "public static int main(String args[])" Watch "public static int main(String args[])" New topic
Author

public static int main(String args[])

Siva Mamillapalli
Greenhorn

Joined: Sep 06, 2007
Posts: 2
Hi All,

I am a new member of this group. Please help me in understandig the following problem.

public class TestClass {

public static int main(String[] args) {

System.out.println("First Test");
return 1;

}

}

I understand that there is no syntax erros in the above code.But while running the above program, I am getting the following error.

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

can any one explain this in the JVM perspective.

Thanks in advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42592
    
  65
Welcome to JavaRanch.

If you run a Java program like this, it needs to have a method "public static void main", not "public static int main". Java is different from C in this regard.


Ping & DNS - my free Android networking tools app
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
[ deleted ]
[ September 06, 2007: Message edited by: Jim Yingst ]

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39773
    
  28
[ deleted ]

Are we risking getting flung off the beginners' forum for asking questions of any difficulty?

[ deleted ]
[ September 06, 2007: Message edited by: Jim Yingst ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Campbell Ritchie:
...Are we risking getting flung off the beginners' forum for asking questions of any difficulty? ...

Yes.

This sidetrack would be a good discussion in the Intermediate forum.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
I've moved the side discussion into a separate thread here.


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: public static int main(String args[])