• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Linux and Java command

 
Sudhanshu Mishra
Ranch Hand
Posts: 236
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am facing a problem whose reason i am unable to understand.
I am running linux on my syatem,and java version 7.0.
When i try to compile a code it does fine,but running a code by java command always gives the error that 'Main method not found.please declare it as pulic static void main(String[] args',even if i have a perfectly written main method like this: public static void main(String...a).
I have already checked the classpath and every thing seems fine.
What could be the possible reason?
Please help me out.
Thanks....
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sudhanshu Mishra wrote:When i try to compile a code it does fine,but running a code by java command always gives the error that 'Main method not found.please declare it as pulic static void main(String[] args',even if i have a perfectly written main method like this: public static void main(String...a).

Please post the actual code, and how are you compiling and running it from terminal.
 
Vinod Vijay
Ranch Hand
Posts: 150
Java Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sudhanshu Mishra wrote:Hi all,
I am facing a problem whose reason i am unable to understand.
I am running linux on my syatem,and java version 7.0.
When i try to compile a code it does fine,but running a code by java command always gives the error that 'Main method not found.please declare it as pulic static void main(String[] args',even if i have a perfectly written main method like this: public static void main(String...a).
I have already checked the classpath and every thing seems fine.
What could be the possible reason?
Please help me out.
Thanks....


Post your code then only may be we can figure it out.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18100
51
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a critical difference between String and String[]. If you don't declare the main method's one and only argument as String[], it won't look like a main method. Java finds methods using their signatures, which are strings of specially-coded text that contain the method name, the return type, and the types of all their parameter arguments, so if you use the wrong parameter type, the wrojng signature will be generated and Java won't find the method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic