wood burning stoves 2.0*
The moose likes Java in General and the fly likes Reading properties file in jar META-INF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Reading properties file in jar META-INF" Watch "Reading properties file in jar META-INF" New topic
Author

Reading properties file in jar META-INF

Rusty Enisin
Ranch Hand

Joined: May 26, 2005
Posts: 107
I have a jar file that has different configurations depending on which stage of development it is in. The build puts the right info in the jar in a properties file. I am having a hard time accessing the properties file if I put it anywhere else other that right next to the class that is using it.

I would like to put the properties file in the META-INF dir of the jar file. Here is the code from a method in a class in the jar. This works if the properties file is next to the class:



I have tried "/system.properties" and "/META-INF/system.properties" but they did not work. Absolute paths work. But our production machines have different paths.

How do I access the properties file in META-INF?


The squeaky wheel gets the grease. Well, that or replaced...
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9932
    
159

Try this:



[My Blog] [JavaRanch Journal]
Rusty Enisin
Ranch Hand

Joined: May 26, 2005
Posts: 107
That did it. Thanks, Jaikiran!
matias Yaryura
Greenhorn

Joined: Sep 15, 2008
Posts: 20
Perfect !! it's very useful!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading properties file in jar META-INF
 
Similar Threads
How to create a jar file that suits this specification?
properties file in a jar
BeanBox problems
deployment and resource bundle problem
classpath ?