English 中文(简体)
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?

最佳回答
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.

问题回答

If you are using IntelliJ IDE just right click on resources package and go to new and then select Resource Boundle it automatically create a .properties file for you. This did work for me .

BalusC is right. Version 1.0.13 is current, but 1.0.9 appears to have the required bundles:

$ jar tf lib/jfreechart-1.0.9.jar | grep LocalizationBundle.properties 
org/jfree/chart/LocalizationBundle.properties
org/jfree/chart/editor/LocalizationBundle.properties
org/jfree/chart/plot/LocalizationBundle.properties

Putting the .properties file under src/ folder at the same level as com solved the problem.

Spring boot project - needed to add "org.jfree.chart.LocalizationBundle" dir structure manually (each dir and subdir) inside resources dir, otherwise didn t work for me.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签