These days I learnt about i18n(internationalization) and properties files in Java. Two problems appeared:
- Converting a property file to Unicode symbols.
- Dealing with the java.util.MissingResourceException: Can’t find bundle for base name…
І. Converting a property file to Unicode symbols.
I was really wondering how to solve this thing but my colleague Lacho shew me the most direct route. If you use EclipseEE IDE folow these steps:
1) Select the target text for convertion
2) Click on the selected text with right button of mouse to open the menu. Choose Convert –> To Unicode Notation. By the way there are also additional options here, for example To UpperCase/ LowerCase and so on.
The snapshots below will help you definitely:
The result look like this:
ІІ. Dealing with the java.util.MissingResourceException: Can’t find bundle for base name…
I found the solution of this exception in this Sun’s blog. If you want to save time, you can look below at the essential citation which I brought from the blog:
You know java is looking for a properties file in a specific locale. You may be baffled why java keeps complaining it can’t find a properties file that is right there. A few things to keep in mind when debugging this type of errors:
1. These resource properties files are loaded by classloader, similar to java classes. So you need to include them in your runtime classpath.
2. These resources have fully-qualified-resource-name, similar to a fully-qualified-class-name, excerpt you can’t import a resource into your java source file. Why? because its name takes the form of a string.
3. ResourceBundle.getBundle(“config”) tells the classloader to load a resource named “config” with default package (that is, no package). It does NOT mean a resource in the current package that has the referencing class.
4. ResourceBundle.getBundle(“com.cheng.scrap.config”) tells the classloader to load a resource named “config” with package “com.cheng.scrap.” Its fully-qualified-resource-name is “com.cheng.scrap.config”