Forums Register Login

How to call an .exe inside the same jar of main class?

+Pie Number of slices to send: Send
Hi

I have a main class that i'm trying to call an .exe that is in the same folder of project and it only works on eclipse. If i build a jar file, put all files inside jar and try to run, it doesn't work. How can i call .exe from a jar?



The project tree is:

-Project
--src
-qemu.exe
-qemu.dll
-linux.img

Thanks.
+Pie Number of slices to send: Send
You can't. Windows doesn't allow you to execute files directly from ZIP / JAR files.

What you can do is unpack those files. Use System.getProperty("java.io.tmpdir") to get the path to the temporary files folder, then copy those files there. You can use Class.getResourceAsStream("/qemu.exe") etc to retrieve InputStreams to them.
Please enjoy this holographic presentation of our apocalyptic dilemma right after this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 4287 times.
Similar Threads
Interrupting a Thread
open a .exe in java (DLL Problem)
Run a ProC or C file from Java
How to Create a new Windows Service
Read file from directory, update contents of the each file
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 02:45:43.