| Author |
Call exe file with parameters in JAVA
|
Joshua Cloch
Ranch Hand
Joined: Apr 27, 2006
Posts: 95
|
|
Hello everyone! In a DOS-based console,if I want to encypt a file "m",I just use an exe file named "crypt" followed by the file name which is going to be encrypt.The command is: crypt m.Then press Enter,that is all. How can I do this in java? I know how to call an exe file in java,but how can I pass a parameters like file name to the exe file? Thanks very much!
|
truehh@hotmail.com
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12926
|
|
You say you already know how to call an exe in Java. That's with the Runtime.exec() method, right? There are several overloaded versions of this method - there's one where you just supply the name of the exe, but there are also versions where you can supply parameters. Look it up in the API documentation.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Joshua Cloch
Ranch Hand
Joined: Apr 27, 2006
Posts: 95
|
|
Thanks very much! The solution is very simple: sample: String[] commands={"c:\\crypt.exe","c:\\counted.lic"}; Runtime.getRuntime().exec(commands);
|
 |
 |
|
|
subject: Call exe file with parameters in JAVA
|
|
|