Troubleshooting

Finding the .properties Files

I've defined a properties file, but my application can't find the file when the getResourceBundle method is called.

When using .properties files for your resource bundles, make sure they are in your system CLASSPATH. Otherwise, you will get a MissingResourceException when calling the getBundle method on the ResourceBundle class. Because the key/value pairs are loaded dynamically, there is no way for the compiler to check to see if you are referencing invalid keys. When you call the getObject or getString methods on a ResoureBundle, you might also get a MissingResourceException. You should handle this by always having a default value for the key.

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.