[brailleblaster] Re: Localizing with PropertyResourceBundle

  • From: "John J. Boyer" <john.boyer@xxxxxxxxxxxxxxxxx>
  • To: brailleblaster@xxxxxxxxxxxxx
  • Date: Sat, 4 Dec 2010 11:33:26 -0600

Thanks. I'll be looking these things over in the next day or two.

Now here's a dumb question. Ant produces a jar file for the 
BrailleBlaster code that I have, which includes a class with a main 
method. However, when I type

java -jar brailleblaster.jar

I get the message "could not load Class-Main." What could cause this?

Thanks,
John

On Sat, Dec 04, 2010 at 04:19:47PM +0000, Michael Whapples wrote:
> Hello,
> Here is the answer to how to get it loaded, it also supports falling 
> back to more and more general forms should a suitable locale not be 
> supported. NOTE: This is a great example of polymorphism as the same 
> call will also load a suitable ResourceBundle class should you have one 
> for the locale, but if no suitable class is present then a properties 
> file is looked for and used if found and the rest of the application 
> need not know how the resource bundle was got.
> 
> In short you want to look at the JDK documentation for 
> ResourceBundle.getBundle calls (there are a few options). You would do 
> best to read that documentation as to the order of how things are 
> chosen, its more lengthy than I want to type out. The two main ones of 
> interest I think are:
> public static ResourceBundle getBundle(String baseName)
> public static ResourceBundle getBundle(String baseName, Locale locale)
> 
> You probably only want to use the ones with ClassLoaders if you want it 
> to be loaded from another location than the main BrailleBlaster jar file.
> 
> Michael Whapples
> On 04/12/10 02:47, John J. Boyer wrote:
> >The tutorial does not discuss PropertyResourceBundle. I'm having a bit
> >of trouble understanding the source code. You are supposed to call the
> >constructor with a Reader type, but Readir is an abstract class, and the
> >user is supposed to implement certain methods. How can this be? How do I
> >tell propertyResourceBundle to read a file?
> >
> >Do the names of the properties files have to conform to a certain
> >format, like blastlocale_en_GB.properties
> >
> >How are characters outside the usual "printable" range represented? For
> >example how would a Hebrew letter be represented in the value of a key?
> >How are different encodings handled?
> >
> >I want to encapsulate all the localization code within one package, so
> >the locale can be specified in a setup routine and when we want to
> >assign a string to a label or mesage we can just call a simple method
> >with the key. I know from experience that unless one gets in the habit
> >of using such a technique in the beginning it is very difficult to apply
> >it later.
> >
> >John
> >
> 

-- 
John J. Boyer; President, Chief Software Developer
Abilitiessoft, Inc.
http://www.abilitiessoft.com
Madison, Wisconsin USA
Developing software for people with disabilities


Other related posts: