Rajat Agarwal
Rajat Agarwal

Reputation: 11

Java config file issue

I want to change language of display text in java application using eclipse IDE. So I am trying to use resourse=ResourceBundle.getBundle("Text",Locale.ENGLISH );

but while running getting error as

Exception in thread "main" java.util.MissingResourceException: Can't 
find bundle for base name Text, locale en".

Can someone help me in solving this. What I understood is I have to get some config file for this, but I not sure from where I can get it.

Please let me know where I can find this file and how to import in project.

Upvotes: 1

Views: 72

Answers (1)

Robin
Robin

Reputation: 36601

Sounds like you want to use a ResourceBundle backed by a Properties file. This is explained here.

It boils down to the following steps:

  • Create Java properties files with the correct names (name is based on the Locale)
  • Make sure those properties files are located on the class path
  • Use ResourceBundle#getBundle with the correct name

More information and examples can be found in the official tutorials:

Upvotes: 2

Related Questions