Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

getBundle()

Thread view: 
keepa - 21 Feb 2006 19:18 GMT
I am trying to load some resources but it is failing with a
MissingResourceException.

First, I have defined my resources as such:

public class AssyrianResources_at extends ListResourceBundle
{
  // resoruces here
}

then I attempt to load it like this:

Locale locale = new Locale("at");
ResourceBundle getBundle("AssyrianResources", locale);

But this fails with a MissingResourceException.

Any ideas? It seems it cannot find my resource class. It is in the same
directory as all of my other class files.

On a related note, when I attempt to format a date with the above
locale ("at"), it fails ( I get the default American locale). The code
looks like this:

Locale locale = new Locale("at");
GregorianCalendar cal = new GregorianCalendar();
String format = "a format string";
String result = String.format(locale, format, cal);

This gives me an English formatted date, not an Assyrian formatted
date. I assume it is related to the above, where it cannot find the
resource bundle.
John O'Conner - 22 Feb 2006 08:29 GMT
> I am trying to load some resources but it is failing with a
> MissingResourceException.
[quoted text clipped - 12 lines]
>
> But this fails with a MissingResourceException.

The ResourceBundle scheme typically wants the base class to exist too.
So you should start with Resources, then create Resources_at, etc. Then
you can load the "at" resources like this:

Locale locale = new Locale("at");
ResourceBundle resources = ResourceBundle.getBundle("Resources", locale);

> Any ideas? It seems it cannot find my resource class. It is in the same
> directory as all of my other class files.

You should use the full package name of the resource file. So, if you
are creating "com.keepa.Resources" and "com.keepa.Resources_at", you
should load using this:

ResourceBundle resources =
ResourceBundle.getBundle("com.keepa.Resources", locale);

> On a related note, when I attempt to format a date with the above
> locale ("at"), it fails ( I get the default American locale). The code
> looks like this:

Have you checked whether DateFormat supports the "at" locale? Find out
using DateFormat.getAvailableLocales().

Regards,
John O'Conner


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.