1

Im able to run exe's in runtime via Runtime.getRuntime().exec(filePath), but this only seems to work for external exe's outside of the jar. I want to run an exe that I've packaged inside of the jar. How would I do this? I'd believe theres a jar load function, because I've seen code that loads it the same way using the name of the file in the jar, but that returns an IO error for me.

Arhowk
  • 901
  • 4
  • 11
  • 22
  • You can refer these two useful posts. http://stackoverflow.com/questions/600146/run-exe-which-is-packaged-inside-jar or http://stackoverflow.com/questions/10896475/unable-to-load-image-from-jar Thanks – Manas Mukherjee Aug 17 '13 at 20:24

1 Answers1

1

You can copy it to a temporary location outside the jar file, I think that is possible.

Vinz243
  • 9,654
  • 10
  • 42
  • 86
  • 1
    It is indeed possible. Shortest way is probably something like: `Path exe = Files.createTempFile(null, ".exe"); Files.copy(MyApplication.class.getResourceAsStream("/MyProgram.exe"), exe, StandardCopyOption.REPLACE_EXISTING); new ProcessBuilder(exe.toString()).redirectOutput(ProcessBuilder.Redirect.INHERIT).start();` – VGR Aug 17 '13 at 21:22