aspose file tools*
The moose likes Linux / UNIX and the fly likes Linux and Java command Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Linux and Java command" Watch "Linux and Java command" New topic
Author

Linux and Java command

Sudhanshu Mishra
Ranch Hand

Joined: May 28, 2011
Posts: 217

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

Joined: Dec 08, 2010
Posts: 1509
    
    5

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.


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Vinod Vijay
Ranch Hand

Joined: Sep 13, 2011
Posts: 141

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.


Vinod Vijay Nair
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16228
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Linux and Java command