Log4j java.lang.NoClassDefFoundError
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4195807/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Log4j java.lang.NoClassDefFoundError
提问by MartK
I couldnt understand what is causing this error:
我不明白是什么导致了这个错误:
ERROR>Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator
ERROR>Caused by: java.lang.ClassNotFoundException: org.apache.log4j.PropertyConfigurator
Already got the log4j-1.2.8.jar
everywhere in the project but I couldnt make it. How can I make this error go away? Thanks!
已经得到了log4j-1.2.8.jar
项目中的所有地方,但我无法做到。我怎样才能让这个错误消失?谢谢!
采纳答案by Jon Skeet
Well, you haven't said what kind of application this is or basically given us anycontext. You need to make sure that the log4j classes are available to the classloader which is loading your application. If it's a standalone application run from the commandline, that's like to just be a case of specifying the -classpath
command-line option. For example:
嗯,你还没有说这是什么类型的应用程序,或者基本上没有给我们任何上下文。您需要确保加载应用程序的类加载器可以使用 log4j 类。如果它是从命令行运行的独立应用程序,那就像指定-classpath
命令行选项一样。例如:
java -classpath .;log4j-1.2.8.jar org.foo.MyApplication
If you can give us more information, we're likely to be able to help you more.
如果您可以向我们提供更多信息,我们很可能能够为您提供更多帮助。
回答by Bharat Goswami
Setp 1 : right click on your main method
第 1 步:右键单击您的主要方法
Step 2 go to run as option then
步骤 2 转到作为选项运行然后
Step 3 go to Run configuration
步骤 3 转到运行配置
Step 4: and add projects or jar files
第 4 步:并添加项目或 jar 文件
now it works.
现在它起作用了。