0

The following scenario:

I'm extending an admin tool for a system of small services compiled as runnable jars. These services use xml configurations in their classpath for a multitude of tasks.

I now want to extract configuration files like db configuration from the compiled jar files and add them dynamically to the classpath. Up until now you needed to recompile the whole suite if you wanted to change the settings for the database, which is all kinds of bad imho.

What I have tried:
java -Xbootclasspath/p:/path/db.xml java -jar Foo.jar - this results in a java vm error java -Xbootclasspath/p:/path/db.jar java -jar Foo.jar - this doesn't seem to do anything, I've tried to find the xml file via the script below in the classpath, but I haven't been able to. The xml lies directly inside the jar (created with jar cvMf db.jar db.xml)

The script I used:

ZipFile zf;
    ZipFile zf;
try{
    zf = new ZipFile("Foo.jar");
} catch(final ZipException e){
    throw new Error(e);
} catch(final IOException e){
    throw new Error(e);
}
final Enumeration e = zf.entries();
while(e.hasMoreElements()){
    final ZipEntry ze = (ZipEntry) e.nextElement();
    final String fileName = ze.getName();
    final boolean accept = Pattern.compile(".*(xml)").matcher(fileName).matches();
    if(accept){
        log.debug(fileName);
    }
}

I hope someone can help with this problem, I'm pretty clueless on what else I could try.

minime
  • 344
  • 3
  • 10
  • So you want to reference the xml file bundled inside the jar? If so You can load resources in the classpath as described http://stackoverflow.com/questions/3294196/load-resource-from-anywhere-in-classpath – Jerome Anthony Dec 03 '14 at 20:12
  • You cannot use -classpath together with -jar. edit: and again, the bootclasspath arguemnt does not seem to add the contents of the jar to my classpath – minime Dec 03 '14 at 20:25

1 Answers1

0

I have repackaged the xml, and now it seems to work fine. Sorry for needlessly posting.

minime
  • 344
  • 3
  • 10