• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to pass arguments dynamically to .exe using Java

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2236
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use this:
Runtime.exec(String[])
 
sanjay kams
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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


 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My parameters are given below.

update -sol "Defects" -proj "Software" -trans "New Defect" -rec "653489"
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic