Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading properties file in jar META-INF

 
Rusty Enisin
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:

 
Rusty Enisin
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That did it. Thanks, Jaikiran!
 
matias Yaryura
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perfect !! it's very useful!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic