<Can't find bundle for base name> is driving me mad
From: F. Da Costa Gomez (dacosta_at_xs4all.nl)
Date: 03/31/04
- Next message: Else Lervik: "J2SE 1.5, JSP and Tomcat"
- Previous message: mistral: "Html into a DOM tree"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Else Lervik: "J2SE 1.5, JSP and Tomcat"
- Previous message: mistral: "Html into a DOM tree"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|