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?
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?
Copyright © 2021 Jogjafile Inc.
A jar file just an archive. You could update it with a
jar --updatetool, which is a part of jdk. It may not work if the jar is signed.Alternatively you could look into (using the
jartool) the jar-file to figure out what is a main class (findMain-Class:in theMETA-INF/MANIFEST.MF). Then run the jar file specifying classpath explicitlyjava -classpath path-with-your-file:theApp.jar.