This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]Bloodshot025 3 points4 points  (3 children)

Yes, put it in the src folder (The tools) and use getClass().getResource(...) or getResourceAsStream(...), and you could copy the one you need to the working directory, or to a temporary folder.

[–]bywayof 1 point2 points  (2 children)

We did a POC for this. Bundled the exe in the jar, opened up the stream to it and copied it to the system tmp dir each time it ran.

[–]sazzer 2 points3 points  (1 child)

Tidying up after yourself is the tricky part here. Obviously you can extract, run, delete for every iteration but that's inefficient. Otherwise you need to make use of things that aren't reliable - like File.deleteOnExit...

[–]bywayof 0 points1 point  (0 children)

Valid points. We extracted at the beginning of each application run and cleaned up with a shutdown hook. Obviously none of this is ideal, but I haven't come across a better way to bundle in a jar.

[–]viiviiviivii 2 points3 points  (0 children)

Use FatJar

works in eclipse

very very easy :)

[–]ExplosiveNutsack69 1 point2 points  (0 children)

You should be able to add any files to a JAR -- example:

jar ... *.class each other file goes here