papafe
papafe

Reputation: 3070

Runtime error NoClassDefFoundError with apache common codec jar

I have a java class (SecureHash) that uses the functionalities of apache common codec. I am compiling the code with

javac -classpath sample/module/commons-codec-1.8.jar  sample/SampleAcn.java sample/module/SampleLoginModule.java sample/module/SecureHash.java 

I do not get any error with compilation, but I get a runtime errors, when the a SecureHash is initialized:

java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException
    at sample.module.SampleLoginModule.login(SampleLoginModule.java:242)
    .....


 Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.DecoderException
     at java.net.URLClassLoader$1.run(Unknown Source)
         .....

I cannot get the reason for this error, as I'm including the jar to the common codec.

Upvotes: 0

Views: 1469

Answers (2)

Akira
Akira

Reputation: 4071

Are you sure you are using the setting the CLASSPATH correctly when you run your classes? You also need to point for the location of sample/module/commons-codec-1.8.jar.

Upvotes: 1

constantlearner
constantlearner

Reputation: 5247

According to the dependencies here you might also need commons-logging, but you've probably already got that.

Upvotes: 0

Related Questions