Resource Bundle, where in the directory

M

Mr. Ink

Hello!

Using Eclipse to code.
Where do i normally store my resource bundles in the project, and how
do I reach that bundle.

String baseName = "MyResources";
ResourceBundle rb = ResourceBundle.getBundle(baseName);

My class never seems to find that bundle, in this case
the file 'MyResources_sv_SE.properties'

Im a able to set out some path to my file, I have not got a clue.

please help, i
 
V

venkatesh.canchi

I presume you are referreing to struts ResourceBundles, if yes, this
you have to configure your resource bundle in struts-config.xml file
underneath WEB-INF directory.

Thanx,
venky
 
B

Bent C Dalager

Hello!

Using Eclipse to code.
Where do i normally store my resource bundles in the project, and how
do I reach that bundle.

String baseName = "MyResources";
ResourceBundle rb = ResourceBundle.getBundle(baseName);

My class never seems to find that bundle, in this case
the file 'MyResources_sv_SE.properties'

It may need to be in the root directory of your classpath.

If your project looks something like this (I have no idea how Eclipse
lays out its directory structure):

project
project/src
project/src/com
project/src/com/us
project/src/com/us/superapp
project/classes
project/classes/com
project/classes/com/us
project/classes/com/us/superapp

Then the resource bundle shold probably be
project/classes/MyResources_sv_SE.properties

I would also double-check that the app's default locale is, indeed,
"sv_SE". If it's, say, "en_US", or just "sv", then it won't even look
for that particular file.
System.out.println(Locale.getDefault());
tends to do the trick :)

Cheers
Bent D
 
T

Thomas Fritsch

Mr. Ink said:
Hello!

Using Eclipse to code.
Where do i normally store my resource bundles in the project, and how
do I reach that bundle.

String baseName = "MyResources";
You have to prepend it with the full package name (supposed you have
your properties file in a package):
String baseName = "my.package.MyResources";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top