Amar
Amar

Reputation: 763

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 issueenter image description here

Upvotes: 0

Views: 2658

Answers (3)

Willam2004
Willam2004

Reputation: 1

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

Upvotes: 0

YMomb
YMomb

Reputation: 2397

Between commons-lang 2.x.x and 3.x.x 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

Upvotes: 1

Karl
Karl

Reputation: 16

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.

Upvotes: 0

Related Questions