Discussion - the powerfull way to excellence!
Gamini Sirisena wrote:You could try to load the property file as a ResourceBundle. This will pick the property file if it is in the Classpath.
So in the jar the property file should be bundled at the same level where the class package structure starts.
Discussion - the powerfull way to excellence!
ram kumar wrote:
How do i do that any code sample.
Will it work for unix machines also.
OCUP UML fundamental and ITIL foundation
Gamini Sirisena wrote:Try here first...
Discussion - the powerfull way to excellence!
ram kumar wrote:
Gamini Sirisena wrote:Try here first...
Is that possible to include that line of code to read as resourceBundle.
Later i will start using it in all my logics
Discussion - the powerfull way to excellence!
ram kumar wrote:Later i will start using it in all my logics
K. Tsang CEng MBCS PMP PMI-ACP OCMJEA OCPJP
K. Tsang wrote:
ram kumar wrote:Later i will start using it in all my logics
Hey Ram, honestly if you want to hard-code the path to the properties file bundle with jar, why don't you just generate it on the fly. Exactly what is in this properties file? Enter these things as properties -D when running java can be another option.
If the really want to bundle the ClassLoader.getResource(...) should work as is. Although the path of the properties file inside the jar needs to be fixed. And I don't suggest you put that file in the default package. Suppose your package structure is:
Put the file in say toppackage then you use "ClassLoader.getResource("toppackage/abc.properties");"
Discussion - the powerfull way to excellence!
K. Tsang CEng MBCS PMP PMI-ACP OCMJEA OCPJP
K. Tsang wrote:Looks ok to me. As long as you get the "expected" output once the Properties is loaded then you should be fine.
Well since you are loading from within jar, but if you are generating on the fly - just to get your head think, what happens if the properties file has read/write access permission problems.
Discussion - the powerfull way to excellence!
Discussion - the powerfull way to excellence!
K. Tsang CEng MBCS PMP PMI-ACP OCMJEA OCPJP
Discussion - the powerfull way to excellence!
Is that a spider in your hair? Here, threaten it with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|