File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

public static int main(String args[])

 
Siva Mamillapalli
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Peter Chase
Ranch Hand
Posts: 1970
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[ deleted ]
[ September 06, 2007: Message edited by: Jim Yingst ]
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[ 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
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've moved the side discussion into a separate thread here.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic