• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

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

 
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.
 
Sheriff
Posts: 21745
102
Chrome Eclipse IDE Java Spring Ubuntu VI Editor 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.
 
Your mother was a hamster and your father was a tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!