This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes Using Runtime.exec() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Using Runtime.exec()" Watch "Using Runtime.exec()" New topic
Author

Using Runtime.exec()

Shankara Sharma
Ranch Hand

Joined: Feb 06, 2012
Posts: 46
Hi All,

I am trying to invoke a Jar file, with command line arguments to the main() method in that Jar file.
So here is the command i am trying to execute

String command = "java lib\test.jar com.test.Test 1234";
Runtime.getRunTime.exec(command);

But that particular jar file is not started after executing the above command.
Please correct me if anything is wrong in this?
Richard Tookey
Bartender

Joined: Aug 27, 2012
Posts: 1166
    
  17

Did you test that command on the command line because I would not expect it to work if you are expecting to execute the class com.test.Test located in the jar file.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12999
    
    5
Specifying the class location that way means you are dependent on your current directory having the "lib" subdirectory.

Why not specify the absolute location?

Bill

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Runtime.exec()
 
jQuery in Action, 3rd edition