Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't find bundle for base name

I'm using a library that has a dependency on jfreechart (v 1.0.9).

When I try to run the .jar, I get:

java.util.MissingResourceException: Can't find bundle for base name         org.jfree.chart.LocalizationBundle, locale en_US     at java.util.ResourceBundle.throwMissingResourceException         (ResourceBundle.java:1521)     at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1260)     at java.util.ResourceBundle.getBundle(ResourceBundle.java:962) 

I've tried creating a LocalizationBundle.properties file, but that didnt do it. I've checked the CLASSPATH, still no go.

Any ideas?

like image 690
Shane Castle Avatar asked Jan 17 '10 23:01

Shane Castle


People also ask

Can t find bundle for base name in eclipse?

This problem is usually happened in the Eclipse IDE environment, where it doesn't copy the “. properties” file extension by default. So, just make sure the properties file is existed in the run time “classes” folder and can be located by your web application.

How do I use ResourceBundle getBundle?

getBundle. Gets a resource bundle using the specified base name, locale, and class loader. This method behaves the same as calling getBundle(String, Locale, ClassLoader, Control) passing a default instance of ResourceBundle. Control .

How do you deal with MissingResourceException?

To fix the MissingResourceException , it should be ensured that any resource required by the program exists with the correct name and at the right location. Any values attempted to be retrieved from a resource file using a key should exist with the right key.

Where does resource bundle properties file go?

ResourceBundle property files contain locale-specific objects for use by Java classes. The ResourceBundle property file must be placed somewhere in the CLASSPATH . Typically this is best accomplished by placing the ResourceBundle properties file in the same directory as the gear message class that it maps to.


1 Answers

java.util.MissingResourceException: Can't find bundle for base name     org.jfree.chart.LocalizationBundle, locale en_US

To the point, the exception message tells in detail that you need to have either of the following files in the classpath:

/org/jfree/chart/LocalizationBundle.properties

or

/org/jfree/chart/LocalizationBundle_en.properties

or

/org/jfree/chart/LocalizationBundle_en_US.properties

Also see the official Java tutorial about resourcebundles for more information.

But as this is actually a 3rd party managed properties file, you shouldn't create one yourself. It should be already available in the JFreeChart JAR file. So ensure that you have it available in the classpath during runtime. Also ensure that you're using the right version, the location of the propertiesfile inside the package tree might have changed per JFreeChart version.

When executing a JAR file, you can use the -cp argument to specify the classpath. E.g.:

java -jar -cp c:/path/to/jfreechart.jar yourfile.jar 

Alternatively you can specify the classpath as class-path entry in the JAR's manifest file. You can use in there relative paths which are relative to the JAR file itself. Do not use the %CLASSPATH% environment variable, it's ignored by JAR's and everything else which aren't executed with java.exe without -cp, -classpath and -jar arguments.

like image 50
BalusC Avatar answered Sep 21 '22 13:09

BalusC