aspose file tools
The moose likes Beginning Java and the fly likes Call exe file with parameters in JAVA Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Call exe file with parameters in JAVA" Watch "Call exe file with parameters in JAVA" New topic
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
    
    3

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);
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Call exe file with parameters in JAVA
 
Similar Threads
calling a exe of fortran from java with a file as an input to the fortran exe
JNI
calling a fortran program from java
How to call EXE from JAVA
Communicate with legacy programme