Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to pass arguments dynamically to .exe using Java  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have an .exe file placed in a directory location. I used the following lines of code to run the .exe file.



But I want the response based on the parameters that I pass to the .exe file. I don't know how to pass the parameters dynamically. Can anyone help on this.

Thanks in advance.
 
Bartender
Posts: 2155
46
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use this:
Runtime.exec(String[])
 
sanjay kams
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Could you please help me, how to use the Runtime.exec(String[]) in the above code?


 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

sanjay kams wrote:But I want the response based on the parameters that I pass to the .exe file. I don't know how to pass the parameters dynamically. Can anyone help on this.


Well, where are your parameters? I don't see any in your code. You can either add them to the end of your command String, separated by spaces, or put them in an array after the command itself and use the method that Pawel suggested (right now, you're NOT).

BTW, I wouldn't code your catch block like that either, because your program will simply carry on after an error.

My advice: Forget the try...catch and just add throws IOException to the method.

Winston
 
sanjay kams
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My parameters are given below.

update -sol "Defects" -proj "Software" -trans "New Defect" -rec "653489"
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!