GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes how to pass the arguments to the main class ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to pass the arguments to the main class ..." Watch "how to pass the arguments to the main class ..." New topic
Author

how to pass the arguments to the main class ...

srinivas daroori
Greenhorn

Joined: Feb 23, 2004
Posts: 18
I am running my application by making it as a jar
like : java -jar application.jar (where application.jar is the jar file which consists my application.)

Now the question is , the main class in my above application requires command line parameters. How can I pass that while I am running it as a jar.
(sth like if I run the application alone I would be running like
java MyApplication processJob

Thanks!
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Type java -? from the command line to get all the syntax options. Here's part of what mine said:

Does the 3rd line look like what you need?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
am running my application by making it as a jar
like : java -jar application.jar (where application.jar is the jar file which consists my application.)

Now the question is , the main class in my above application requires command line parameters. How can I pass that while I am running it as a jar.
(sth like if I run the application alone I would be running like
java MyApplication processJob


Same thing when you run it for a jar:

jajav -jar application.jar processJob
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Moving to Java in General (Beginner). Followups there, please.


[Jess in Action][AskingGoodQuestions]
 
GeeCON Prague 2014
 
subject: how to pass the arguments to the main class ...