java.lang.ClassNotFoundException:org.apache.commons.text.WordUtils [英] java.lang.ClassNotFoundException: org.apache.commons.text.WordUtils
本文介绍了java.lang.ClassNotFoundException:org.apache.commons.text.WordUtils的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道为什么在这里得到ClassNotFoundException,因为我已经为WorkUtils编译了适当的jar文件,而WordUtils类显然在jar文件中.
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.
我使用 javac -d bin -cp lib/commons-text-1.2.jar MyClass.java
进行了编译并使用 java -cp bin MyClass
I compiled with javac -d bin -cp lib/commons-text-1.2.jar MyClass.java
and run with java -cp bin MyClass
这是我的java类:
import org.apache.commons.text.WordUtils;
class MyClass
{
public static void main(String[] args) {
System.out.println(WordUtils.capitalize("sample text"));
}
}
我收到此错误:
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?
推荐答案
该库还必须发送到 java
:
java -cp bin:lib/commons-text-1.2.jar MyClass
如果您使用的是Windows,则可能需要将:
替换为;
If you're on Windows, you may need to replace :
with ;
这篇关于java.lang.ClassNotFoundException:org.apache.commons.text.WordUtils的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文