0

I am making a small tool in Eclipse which needs to run a C executable - the file is in one of the packages and runs fine inside the IDE.

When I try to package it as a .jar though, nothing seems to work - InvocationTargetException, NullPointerException, they've all showed up while trying to fix it, and I'm pretty sure the .jar doesn't work because files can't be accessed inside it without using getResourceAsStream(). I've tried using getResource() but it just returns variations of where the file should be - but it can't be accessed as it's in a jar.

Many questions here of the same nature are answered by using getResourceAsStream(), but I'm not sure that works for an executable. Is there a way to access a file inside a .jar other than the resource stream method? Or am I just thinking of this the wrong way, and there's a simple solution I'm missing?

platelminto
  • 318
  • 3
  • 16
  • 1
    Why not take the file *out* of the jar executable and make sure that it is in the classpath? – Hovercraft Full Of Eels Sep 03 '16 at 17:05
  • 3
    No, there is no other way. A resource inside a JAR must be accessed with an `InputStream`. What do you want to do then? Executable should be outside of a JAR. http://stackoverflow.com/questions/20389255/reading-a-resource-file-from-within-jar – Tunaki Sep 03 '16 at 17:06
  • 1
    JARs are for **Java** resources. An executable can hardly been seen as a resource ... – GhostCat Sep 03 '16 at 17:10

0 Answers0