问题描述
我正在使用一个依赖于jfreechart的库(v 1.0.9)。
I'm using a library that has a dependency on jfreechart (v 1.0.9).
当我尝试运行.jar时,我得到:
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)
我尝试过创建LocalizationBundle.properties文件,但没有做到这一点。我已经检查了CLASSPATH,但仍然没有。
I've tried creating a LocalizationBundle.properties file, but that didnt do it. I've checked the CLASSPATH, still no go.
任何想法?
推荐答案
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
或
/org/jfree/chart/LocalizationBundle_en.properties
或
/org/jfree/chart/LocalizationBundle_en_US.properties
另见更多信息。
但由于这实际上是第三方托管属性文件,因此您不应自行创建。它应该已经在JFreeChart JAR文件中可用。因此,请确保在运行时期间在类路径中提供它。还要确保使用正确的版本,包树中的属性文件的位置可能已根据JFreeChart版本更改。
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.
执行JAR文件时,可以使用 -cp
参数指定类路径。例如:
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
或者你可以在JAR中将类路径指定为 class-path
条目清单文件。您可以在那里使用相对于JAR文件本身的相对路径。 不使用%CLASSPATH%
环境变量,JAR的忽略以及其他未执行的操作 java.exe
没有 -cp
, -classpath
和 -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.
这篇关于无法找到基本名称的包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!