• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Logan Knecht
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no idea why it's giving me

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

this, could someone explain?

[ July 22, 2008: Message edited by: Logan Knecht ]
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main method is recognized as the entry point for an application only if it's defined as "public static void main (String[] args)". You can't redefine the type of the parameters to be something else.
 
Logan Knecht
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay I understand what you're saying about having to have string args[] as the starting point, is there a way to set the starting point?
[ July 22, 2008: Message edited by: Logan Knecht ]
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. That's hardwired into the "java.exe" executable.
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think there is no need to set the starting point
You can just use the main method ,
use the String arguments
and convert them to ints and get your work done




Hope this helps
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That little example won't compile. You would have to call
. . . testSum(Integer.parseInt(args[0]), . . .

That is prone to a NumberFormatException or an ArrayOutOfBoundsException if you don't pass two integers as command-line arguments . . .

java Parameters 123 456

would work.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!