This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ResourceBundle / Properties

 
Bobby Cunningham
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my application I currently use the Properties class to read in my properties well that works fine, my only problem w/ that is that I have to hard code the path to the properties file in my code and when I change environments I have to change the path.

With ResourceBundle I don't have that problem b/c I just put in the package name for the path!!

ex.

ResourceBundle connInfo = ResourceBundle.getBundle("com.rockwell.powersystems.compint.resources.dbpool");

vs.

filePath = "../../apps/tomcat50-jwsdp/sites/compint.dev-ptwizard/webapps/compint.dev-ptwizard/WEB-INF/classes/com/rockwell/powersystems/compint/resources/";

props.load(new FileInputStream(filePath + "dbpool.properties"));

Help plz. . . Again the class files are looking for Properties but I don't know how to give it to them clean
 
Scott Selikoff
author
Saloon Keeper
Posts: 4032
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This doesn't sound like a JDBC issue but to answer your question:

Put the properties file in the class-path of the JAR to make them run-time accessible or add a JVM property that specifies its location.

For your example, I prefer ClassLoader.getResourceAsStream(), you can then load them using Properties.load(). You access to a class object though often done by calling this.getClass().getClassLoader.getResourceAsStream().
 
Bobby Cunningham
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for posting in the wrong forum but thanks for the tip!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bobby,
Welcome to JavaRanch! I'm moving this to our Java In General forum for filing.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic