Classpath resolution priorities when running a jar
925216Mar 20 2012 — edited Mar 21 2012Hello everybody,
Here is my question. I made a runnable Jar file for my application that is structured like below :
rootFolder/
- conf/
-- my.properties
- script/
-- theJar.jar (containing myOther.properties)
- lib/
-- mylibs.jar (...)
I customized the MANIFEST file like this :
(..)
Main-Class : com.my.MainClass
Classpath : ../conf/ ../lib/mylib1.jar ../lib/mylib2.jar...
(..)
When I run my app with "java -jar theJar.jar", the properties used are the ones inside the jar "myOther.properties" (packaged with Maven). But I want my jar to use the properties located in upper "conf" folder (built by Maven assembly).
I succeeded with using the command line : "java -cp conf/;lib/;script/theJar.jar com.my.MainClass".
So, what is the underground management used by java launcher to discover properties files in classpath? Why does "-cp" override manifest declaration?
Thanks in advance.