472,353 Members | 1,242 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

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

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.throwMissingResourceExcep tion(Unknown Source)
at java.util.ResourceBundle.getBundleImpl(Unknown Source)
at java.util.ResourceBundle.getBundle(Unknown Source)
at multilanguage.PropertiesDemo.displayValue(Properti esDemo.java:25)
at multilanguage.PropertiesDemo.main(PropertiesDemo.j ava: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
Jul 17 '05 #1
0 15161

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Weston C | last post by:
I'm trying to get the href attribute from the base tag in the document head. The following does not seem to work... any ideas what I'm doing wrong?...
3
by: Christopher | last post by:
I came across this line in a lib I am studing, it simply has class cSceneNode; all by itself. what is that line doing? I am used to seeing a...
2
by: CD | last post by:
Is this possible: class base; class derived; //:public base vector <base*> bList; vector<derived*> dList; //add some derived class pointer...
2
by: Siemel Naran | last post by:
This code fails compile std::auto_ptr<Base> f() { std::auto_ptr<Derived> out(new Derived()); return out; } There is ambiguity between a...
3
by: Gilbert Saint-Flour | last post by:
Hello: I have this one line of PHP code which I'd like to convert to Javascript. The PHP code conditionally issues a BASE statement when the html...
3
by: SJ | last post by:
Hi, I have a problem with the HTML <base> element, URL re-writing and Postback. We are using URL re-writing on the server, and I'd like to use...
3
by: noreponse1 | last post by:
Hello, I have a solution that contains two projects. I have 2 dlls that these projects use. Here's how it's set up: Solution -ProjectA...
1
by: MAILTONRK | last post by:
Hi, I am a Mainframe guy. I am working with MS access(maintaining a application) for the last 2 weeks. I had one master database and four...
3
by: yan | last post by:
Hello everybody, I am new so this is the occasion to say hello to everybody. I have a problem with absolute/relative paths. I have to create a...
16
by: call_me_anything | last post by:
why is the following not allowed : vector <Base *vec_of_base; vector <Derived *vec_of_derived; vec_of_base = vec_of_derived; Note : The...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.