• 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
Bartender
Posts: 4033
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
Sheriff
Posts: 36031
432
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.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!