• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
David de Lucca
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Pie
Posts: 20613
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic