Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Loading a ResourceBundle

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
If somebody says you look familiar, tell them you are in porn. Or in these tiny ads:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic