<Can't find bundle for base name> is driving me mad

From: F. Da Costa Gomez (dacosta_at_xs4all.nl)
Date: 03/31/04


Date: Wed, 31 Mar 2004 13:19:11 +0200


Hi all,

Although i'm not a complete newbie i do feel like one at the moment.

This question concerns the use of the ResourceBundle as per the example in
the Trail tutorial on java.sun.com (thus it should be simple, right?).

The error:
java.util.MissingResourceException: Can't find bundle for base name
LabelsBundle, locale en_US
        at java.util.ResourceBundle.throwMissingResourceException(Unknown Source)
        at java.util.ResourceBundle.getBundleImpl(Unknown Source)
        at java.util.ResourceBundle.getBundle(Unknown Source)
        at multilanguage.PropertiesDemo.displayValue(PropertiesDemo.java:25)
        at multilanguage.PropertiesDemo.main(PropertiesDemo.java:46)

Attached is the code and the three prop files i (try to) use.

I know about the classpath suggestions that can be found all over the place
but the prop files are just sitting nicely in the same dir where the
PropertiesDemo.class file resides (and is started from). This suggests to
me that the classpath is ok (right?).

Should not matter but i'm using Eclipse 3M7.

If anybody could help me out here i would really appreciate it. It is
already bugging me for more than 4 hours now :-[[

TIA
Fermin DCG


package multilanguage;

/*
 * Copyright (c) 1995-1998 Sun Microsystems, Inc. All Rights Reserved.
 *
 * Permission to use, copy, modify, and distribute this software
 * and its documentation for NON-COMMERCIAL purposes and without
 * fee is hereby granted provided that this copyright notice
 * appears in all copies. Please refer to the file "copyright.html"
 * for further important copyright and licensing information.
 *
 * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
 * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 */

import java.util.*;

public class PropertiesDemo {

        static void displayValue(Locale currentLocale, String key) {
                ResourceBundle labels = ResourceBundle.getBundle("LabelsBundle"/*, currentLocale*/);

                String value = labels.getString(key);
                System.out.println("Locale = " + currentLocale.toString() + ", " + "key = " + key + ", " + "value = " + value);
        } // displayValue
        
        static void iterateKeys(Locale currentLocale) {
                ResourceBundle labels = ResourceBundle.getBundle("LabelsBundle", currentLocale);
                Enumeration bundleKeys = labels.getKeys();
                while (bundleKeys.hasMoreElements()) {
                        String key = (String) bundleKeys.nextElement();
                        String value = labels.getString(key);
                        System.out.println("key = " + key + ", " + "value = " + value);
                }
        } // iterateKeys
        
        public static void main(String[] args) {
                //Locale.setDefault(new Locale("en_US"));
                Locale[] supportedLocales = {Locale.FRENCH, Locale.GERMAN, Locale.ENGLISH};
                
                for (int i = 0; i < supportedLocales.length; i++) {
                        displayValue(supportedLocales[i], "s2");
                }
                
                System.out.println();
                iterateKeys(supportedLocales[0]);
        } // main

} // class



#s1 comment
s1=computer

#Comment s2
s2=Platte

#Comment s3
s3=Monitor

#Comment keyboard
s4=Tastatur



#s1 comment
s1=computer

#Comment s2
s2=disk

#Comment s3
s3=monitor

#Comment keyboard
s4=keyboard



#s1 comment
s1=fr_computer

#Comment s2
s2=fr_disk

#Comment s3
s3=fr_monitor

#Comment keyboard
s4=fr_keyboard



#s1 comment
s1=computer

#Comment s2
s2=disk

#Comment s3
s3=monitor

#Comment keyboard
s4=keyboard



Relevant Pages

  • <Cant find bundle for base name> is driving me mad
    ... Attached is the code and the three prop files i use. ... * Copyright 1995-1998 Sun Microsystems, ... public class PropertiesDemo { ... #Comment keyboard ...
    (comp.lang.java)
  • SUMMARY: Master View USB KVM switch on Sun Blade 150?
    ... CS-104U KVM is. ... deprecated for the Sun Blade 150. ... then it wouldn't startx (presumably becuase there is no keyboard). ... USB device and the ATENs either dont respond or respond in a manner ...
    (SunManagers)
  • Re: Ultra 10 - no output to monitor
    ... Sun Ultra 10 Elite 3D with 512MB ... SymBios 22801 SCSI card ... keyboard and monitor connected. ... but the monitor remains black. ...
    (comp.sys.sun.hardware)
  • 7011-250 with GXT150 Problems
    ... Sun and SGI equipment. ... as I have a keyboard and mouse from an X-Station ... Or is the card just plain dead? ...
    (comp.unix.aix)
  • Re: <Cant find bundle for base name> (solved)
    ... > Attached is the code and the three prop files i use. ... > me that the classpath is ok. ... > * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, ... > #Comment keyboard ...
    (comp.lang.java)