Skip to main content

Accessing JAR files

1 reply [Last post]
Joined: 2010-05-30


I have a project which calls an internal jar included in it´s classpath. At a certain moment my code makes this call:

Runtime.getRuntime().exec("java -jar ./jars/myJar.jar");

It works when running from Netbeans, but when I make "clean and build" and then execute the new jar ( outside of Netbeans ), doesn´t work the execution of myJar.jar (I mean: the main project works, but myJar execution don´t). I guess the path is modifyed, because the internal jar is included in the main jar.

How could I reach my internal jar file path when executing the entire project made a jar file?


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2010-04-24

you must extract it from the jar if it is packed in. Java cannot run a class in a .jar that is itself packed in an other .jar package.
Simply use the ZipDeflate tools, it should work.