I'm trying to use DigestUtils class from org.apache.commons.codec.digest and I imported it in java like this:
import org.apache.commons.codec.digest.DigestUtils;
When I run it in Eclipse, it works. But when I try to run it from Command Prompt (with "java Simhash"), I'm getting this:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/digest/DigestUtils
at Simhash.main(Simhash.java:17)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.digest.DigestUtils
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
I'm a total Java-newbie. I downloaded commons-codec-1.10.jar file, put it in my project folder and imported it with Build Path -> Configure Build Path -> Add External JARs...
Any idea?
Add the JAR file to your command line runtime classpath
java -cp commons-codec-1.10.jar;. Simhash
This should also simply run directly from Eclipse as youve already added the file to the classpath.