-2

Upon trying to run my code, I get this problem:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/digest/DigestUtils
    at primjer.ZastitniKodIzracun.main(ZastitniKodIzracun.java:67)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.digest.DigestUtils
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    ... 1 more

If I understood well, this could be due to an error in naming/saving the files which compose the project, but I'm not sure what's the problem - the name of the Java source code file corresponds to the text of the "public class" line in the code (ZastitniKodIzracun.java). I'm working in Eclipse. The beginning of the code goes like this:

import java.io.FileInputStream;
import java.security.Key;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.Signature;
import java.util.Date;
import java.text.SimpleDateFormat;
import org.apache.commons.codec.digest.DigestUtils;
Prothy
  • 47
  • 2
  • 7
  • If you are using version 1.15 of [Apache Commons Codec](https://commons.apache.org/proper/commons-codec/), make sure that file **commons-codec-1.15.jar** is included in the dependencies in your run configuration in Eclipse. – Abra Sep 23 '21 at 15:53
  • 1
    Does this answer your question? [How do I resolve ClassNotFoundException?](https://stackoverflow.com/questions/17408769/how-do-i-resolve-classnotfoundexception) – st.huber Oct 01 '21 at 08:38

1 Answers1

0
java.lang.ClassNotFoundException: 

Most of the times this happens when the required library (and all of its dependencies) is not in classpath for runtime. Make sure the appropriate version of the dependency lib is packaged (or) available for runtime (not just compile time).

kosa
  • 65,990
  • 13
  • 130
  • 167