简体   繁体   中英

Apache Commons Lang Exception

I am trying to use StringUtil class from Apache Commons Lang jar (commons-lang3-3.1-bin.zip) .
So I added this jar to my class path and I ran that program.
When I ran my code I am getting an exception like
"Caused by:java.lang.ClassNotFoundException:org.apache.commons.lang.StringUtils" .

I opened this class using java decompiler and when I opened its showing as
"// INTERNAL ERROR //" . Except this class all other classes are fine.

After that I downloaded the source code and I compile that class and I opened that compiled class in java decompiler then it also shows the same error. So how can I solve this issue and how can I use this issue 在此处输入图片说明

Between commons-lang 2.xx and 3.xx the packages have move from org.apache.commons.lang (that is missing to your code according to the exception) to org.apache.commons.lang3 as presented in your screenshot.

Either you downgrade to commons-lang 2.6 or you update your code to change the import declaration from org.apache.commons.lang.StringUtils to org.apache.commons.lang3.StringUtils

Make sure the file you downloaded is right.

Make sure the jar you added to your project isn't commons-lang3-3.1-bin.zip , but is commons-lang3-3.1.jar in commons-lang3-3.1-bin.zip.

http://commons.apache.org/proper/commons-lang/article3_0.html

Java code Despite the label of backwards incompatibility, in the vast majority of cases the simple addition of a '3' to an import statement will suffice for your migration.

Change: import org.apache.commons.lang -> import org.apache.commons.lang3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM