0

We currently have a library that compiles to a jar and is used widely by the company. The jar contains an xml file that sets properties for our cache. In order to change values in the xml file, it seems we need to unzip the jar, change the xml file properties and repackage.

Is there a better way considering this jar is a dependency that is just expected to work from other components without extra setup? The property file is loaded from a ClassLoader.getResource call using the filename of the resource.

Mike
  • 609
  • 12
  • 36
  • In other way, you can make a copy of the xml file and place it outside the jar (in the same folder where you place your jar file). And in the jar file code, tell it to look for the xml file outside the jar. so that your xml changes wont depend on jar file. – The Guest Mar 05 '18 at 16:42
  • What do you mean by "tell it to look for xml file outside the jar"? How do I do that? – Mike Mar 05 '18 at 16:47
  • URL url = YOURCLASS.class.getResource("YOURCLASS.class"); if(url.getProtocol().startsWith("jar")){ read xml file from the jar file directory } – The Guest Mar 05 '18 at 16:51
  • @Mike Is https://stackoverflow.com/questions/1708534/can-i-use-the-classpath-to-override-a-file-in-a-jar-that-is-being-run an option? – Progman Mar 05 '18 at 19:10

0 Answers0