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 Executing .exe inside a jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Executing .exe inside a jar file" Watch "Executing .exe inside a jar file" New topic
Author

Executing .exe inside a jar file

S.L.Narayanan
Ranch Hand

Joined: Apr 01, 2005
Posts: 431
Hi ranchers

I am creating a small application which I am going to deliver as a jar file. The main class inside that jar file has to execute one .exe file if some condition is satisfied. I have put the exe file also inside the jar. But while running the jar file, it is not executing the .exe file. If I put the .exe file inside the folder from where I am running the jar file then it is working fine. But I cannot deliver as a jar file and a exe file.What can I do now?

By the way, I am using Runtime.getRuntime().exec() method to execute the exe file from the java program. Help me out friends.


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, NEXT--->IBM XML
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41818
    
  62
You won't get it to execute from within the jar file - you need to extract it into the directory, and run it from there.


Ping & DNS - my free Android networking tools app
Dale Seng
Ranch Hand

Joined: Mar 22, 2004
Posts: 275
If it wasn't clear from the previous post, you might try opening the jar file (that you know must be there, since that's where your app starts), searching for the exe, and writing it out to the local directory. You could also clean-up (delete) the file if you want. The classes you need are contained in standard Java (java.util.zip).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Executing .exe inside a jar file