Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Classpath resolution priorities when running a jar

925216Mar 20 2012 — edited Mar 21 2012
Hello 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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 18 2012
Added on Mar 20 2012
12 comments
1,625 views