• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about ResourceBundle

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I back a ResourceBundle with Properties Files on the disk, and name it MyResourceBundle_en_US.properties.
When I try to get the bundle by using
ResourceBundle bundle =
ResourceBundle.getBundle("MyResourceBundle",currentLocale);
How does the JVM know which directory on the disk it should look for the properties file? Does it search for the entire disk?
Thanks.
Arnold
 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in a web app, the searching is similar to that of looking for a class under the WEB-INF/classes dir. In this case 'MyResourceBundle.properties' is understood to be directly in the 'classes' folder. If the file is in another dir say '/WEB-INF/classes/com/here/' then the parameter passed to the getBundle method should be fully qualified to guide the searching e.g.
ResourceBundle bundle =
ResourceBundle.getBundle("com.here.MyResourceBundle",currentLocale);
Used ResourceBundles in jsp web app dev but haven't tried it in other cases. Probably in other cases (such e.g. java app), the .properties file, if unqualified, will be searched in the location of the class using it. If in another location, might need to have it jarred and register it in classpath in order to be accessed.
 
Being a smart alec beats the alternative. This tiny ad knows what I'm talking about:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic