• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Runtime.exec()

 
Shankara Sharma
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic