1
donuts
4y

If I app.properties in src/resources in a jar.
And load it in code I guess using Classloader.getResource()?

Can I override it at runtime? By I guess adding a different file but with same name into the classpath?

Comments
  • 0
    I would assume if you have a directory in the class path that is evaluated before the jar is analyzed, it might? Easy enough to testbed.
  • 0
    @SortOfTested was wondering if there was a formal order. Like if cp is /etc/*; lib/*.jar

    Then even though the jar has app.properties, it will use etc/app. Properties?

    Yes I guess could do trial and error but was wondering if there's a formal doc. Not sure what to Google for this but whatever I searched don't find what I wanted.
  • 0
    you can it override per commandline parameters
  • 0
    @stop like -Dapp.properties=x.properties?

    getResources will return x assuming it's added to -cp x.propeties; ...

    Actually yes I should just try it myself... But was wondering if there some formal doc that has the precedence order...
  • 1
    Whichever appears first in the classpath gets picked up
  • 1
    I'm glad I don't do Java 🤗
  • 3
  • 1
    @yellow-dog That's correct!
  • 1
    @ScriptCoded I'm not glad I do Java
Add Comment