How to call an .exe inside the same jar of main class?
David de Lucca
posted 5 years ago
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?
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.