File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes running  exe files from JAR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "running  exe files from JAR " Watch "running  exe files from JAR " New topic
Author

running exe files from JAR

Govind battacharya
Greenhorn

Joined: Sep 25, 2003
Posts: 3
Dear All
How can i run an EXE file from a JAR application
i am using the following code, but it is not working. please help
Process Process;
process =Runtime.getRuntime().exec("Native.exe");
before making a JAR it was working, but from inside the jar i am not able to call this Native.exe file
please help
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Govind,
The .exe needs to be in the path for the OS to find it.
Also, welcome to JavaRanch!! Please change your name to be compliant with JavaRanch's naming policy. It should not be obviously fictitious.
Your displayed name should be 2 separate names with more than 1 letter each. We really would prefer that you use your REAL name.
You can change your name: here.
Thanks,
Cindy


"JavaRanch, where the deer and the Certified play" - David O'Meara
Govind battacharya
Greenhorn

Joined: Sep 25, 2003
Posts: 3
i didi'nt understood, can u give the code
(i have specified my real name only)
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Thanks for changing your name.
I am kinda swamped right now, but when you ask the operating system to execute a program, such as Native.exe it starts searching for that program following the directories that are named it the os's path parameter. This is different from the classpath that the JVM uses to search for class files.
Your choices are to
- modify the path that the user has on their machine (perhaps by dynamically concatenating onto the existing path in a bat or sh file)
- or you can name the full path for finding the Native.exe program
- you could try to get the user to put that .exe file someplace and track where they put it
In any case, once you start doing any of these you start making the solution dependant on the operating system. But then when you created the Native.exe program you must have compiled it for only one specific operating system anyway.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: running exe files from JAR