• Post Reply Bookmark Topic Watch Topic
  • New Topic

Loading a ResourceBundle

 
David Irwin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All,

I have an application where I would like to make use of a ResourceBundle. I would like to use a .properties file but I'm not sure on the rules on where I can legally put the file. If I have a folder structure that looks like the following:

-- conf (contains all my configuration files)
|- org.myapp (compiled class files)

I would ideally like my ServerResources_en.properties file to be in the conf folder. However, using the UIDefaults class in the javax.swing package, I can't get it load my resource properties file (either in the conf or org.myapps package). However, if I copy the source code of the UIDefaults class and create a UIDefaultsTest class in my project, then both approaches work. For example:

This works:


This works too:


Note: the AppDefaults class extends the UIDefaultTest class. But if my AppDefaults class extends the javax.swing.UIDefaults class, then everything fails. I suspect the classpath is at it again!

Per the ResourceBundle JavaDocs, it states:


Otherwise, getBundle attempts to locate a property resource file. It generates a path name from the candidate bundle name by replacing all "." characters with "/" and appending the string ".properties".


Bottom line: can I place a ResourceBundle properties file outside of my class package structure, and if so what's the best way to do it?

Thanks.

[ February 09, 2006: Message edited by: David Irwin ]
[ February 09, 2006: Message edited by: David Irwin ]
 
David Irwin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A little further testing and I've found the following:

This works:



However, this fails:



where the AppDefaults class extends the javax.swing.UIDefaults class.

What's wrong?

PS. I'm running build 1.6.0-rc-b61.
[ February 09, 2006: Message edited by: David Irwin ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!