> I want to package and run an exe within an executable jar file. I've
> tried using the getClass().getResource("relative/exe/location"), but
[quoted text clipped - 8 lines]
> Process proc =
> rt.exec(this.getClass().getResource("/myexe.exe").toString());
> I would appreciate any help or suggestions on the subject. We've
> considered extracting it an running it from a temp location and
> cleaning up the directory, but we would like to avoid this.
>> I want to package and run an exe within an executable jar file. I've
>> tried using the getClass().getResource("relative/exe/location"), but
[quoted text clipped - 20 lines]
> since I feel it would be the best solution. Why do you
> want to avoid that?
Think of all the issues it creates:
* The need to find a writeable temp directory
* The need to find a unique name to extract it to
* The problem of what to do if there isn't sufficient free space
* The impossibility of always deleting ithe executable afterward
None of these is insuperable, but it would be easier not to deal with them,
if that were possible (which it isn't.)
bkennedy_pu - 14 Jul 2006 18:27 GMT
I am running a windows environment, but the reasons mike brought up are
exactly the reasons why we don't want to extract the files.
> >> I want to package and run an exe within an executable jar file. I've
> >> tried using the getClass().getResource("relative/exe/location"), but
[quoted text clipped - 30 lines]
> None of these is insuperable, but it would be easier not to deal with them,
> if that were possible (which it isn't.)
Morten Alver - 17 Jul 2006 10:19 GMT
>>>I want to package and run an exe within an executable jar file. I've
>>>tried using the getClass().getResource("relative/exe/location"), but
[quoted text clipped - 25 lines]
> * The need to find a writeable temp directory
> * The need to find a unique name to extract it to
You can do it like this (from
http://javaalmanac.com/egs/java.io/CreateTempFile.html):
File temp = File.createTempFile("pattern", ".suffix");
... which finds the proper directory for you, and makes up a unique name.
> * The impossibility of always deleting ithe executable afterward
According to the page linked above you can use:
// Delete temp file when program exits.
temp.deleteOnExit();
... but I'm not sure if that method guarantees that the file will be
deleted.

Signature
Morten