java.lang.ClassNotFoundException: org.apache.commons.text.WordUtils

spectrum :

I can't figure out why I'm getting a ClassNotFoundException here, since I have compiled with the appropriate jar file for WorkUtils, and the class WordUtils is clearly in the jar file.

I compiled with javac -d bin -cp lib/commons-text-1.2.jar MyClass.java and run with java -cp bin MyClass

Here is my java class:

import org.apache.commons.text.WordUtils;

class MyClass
{
    public static void main(String[] args) {

        System.out.println(WordUtils.capitalize("sample text"));

    }
}

I get this error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/text/WordUtils
    at MyClass.main(MyClass.java:11)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.text.WordUtils
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

Anyone know what could be going wrong here?

ernest_k :

The library must also be sent to java:

java -cp bin:lib/commons-text-1.2.jar MyClass

If you're on Windows, you may need to replace : with ;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

java.lang.ClassNotFoundException: org.apache.commons.lang.UnhandledException

org.apache.commons.lang.SerializationException: java.lang.ClassNotFoundException

java.lang.ClassNotFoundException: org.apache.commons.digester.Rule

java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory

java.lang.ClassNotFoundException: org.apache.commons.logging.Log

java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils from BaseClassLoader

Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.builder.EqualsBuilder

java.lang.ClassNotFoundException: org.apache.commons.lang.builder.ToStringBuilder

Error: java.lang.ClassNotFoundException: org.apache.commons.collections4.map.LinkedMap

Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils

java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64

Exception: java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource

How to fix 'org.apache.commons.logging.LogConfigurationException: java.lang.ClassNotFoundException' in quarkus native image

Maven - ClassNotFoundException: org.apache.commons.lang.StringUtils

Apache Commons Configuration: ClassNotFoundException: org.apache.commons.beanutils.DynaBean

java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer

How to use org.apache.commons.lang namespace in Java?

java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils

#java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester

java.lang.AbstractMethodError: org.apache.commons.dbcp.PoolingDataSource

java.lang.ClassNotFoundException: org.apache.spark.sql.Dataset

java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException

java.lang.ClassNotFoundException: org.apache.pdfbox.multipdf.PDFMergerUtility

java.lang.ClassNotFoundException: org.apache.catalina.core.ThreadLocalLeakPreventionListener

java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlObject Error

java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver

java.lang.NoSuchMethodError: org.apache.commons.lang.StringUtils.isBlank(Ljava/lang/String;)Z Error

NoClassDefFoundError : org.apache.commons.lang.StringUtils

java.lang.NoClassDefFoundError: org/apache/commons/lang3/ObjectUtils