MartK
MartK

Reputation: 614

Log4j java.lang.NoClassDefFoundError

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!

Upvotes: 3

Views: 27810

Answers (2)

Bharat Goswami
Bharat Goswami

Reputation: 21

Setp 1 : right click on your main method

Step 2 go to run as option then

Step 3 go to Run configuration

Step 4: and add projects or jar files

now it works.

Upvotes: 2

Jon Skeet
Jon Skeet

Reputation: 1503090

Well, you haven't said what kind of application this is or basically given us any context. 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:

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.

Upvotes: 9

Related Questions