Java – Convertion & java.util.MissingResourceException

“Java” is a category in my blog where I will scratch some tricks and solved problems appeared in my job.

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”

Advertisements

About tsvetanv

Friends, Books, Music, Math, Programming.
This entry was posted in Java. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s