Fixing NoClassDefFoundError in VSCode

Viewed 1045

I just moved from using Atom to write Java to using VSCode to be able to use external libraries. Specifically, I need to be able to read and write to .xlsx files. To do this I'm using Apache POI. I've added it to my Java project under "Referenced Libraries" and am storing it in a /lib folder in my project folder.

See this here.

After doing this, I was able to import the classes I needed without the editor showing anything wrong, but when I tried to run my code, a NoClassDefError is thrown when I try to use anything from the imported classes.

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/io/output/UnsynchronizedByteArrayOutputStream
        at QuestionSet.exportToKahoot(QuestionSet.java:100)
        at QuestionSet.main(QuestionSet.java:136)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream
        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)
0 Answers
Related