Reputation: 8305
A jar loads a file that is packaged inside the jar itself by using getResourceAsStream
.
Is it possible to replace/override that file when running java -jar
without modifying the jar itself?
Upvotes: -1
Views: 85
Reputation: 28981
A jar file just an archive. You could update it with a jar --update
tool, which is a part of jdk. It may not work if the jar is signed.
Alternatively you could look into (using the jar
tool) the jar-file to figure out what is a main class (find Main-Class:
in the META-INF/MANIFEST.MF
). Then run the jar file specifying classpath explicitly java -classpath path-with-your-file:theApp.jar
.
Upvotes: 0