java.lang does not contain a class called StringUtils. Several third-party libs do, such as Apache Commons Lang or the Spring framework. Make sure you have the relevant jar in your project classpath and import the correct class.

Answer from Jonik on Stack Overflow
🌐
Apache Commons
commons.apache.org › proper › commons-lang › apidocs › org › apache › commons › lang3 › StringUtils.html
StringUtils (Apache Commons Lang 3.20.0 API)
org.apache.commons.lang3.StringUtils · public class StringUtils extends Object · Operations on String that are null safe. IsEmpty/IsBlank - checks if a String contains text · Trim/Strip - removes leading and trailing whitespace · Equals/Compare - compares two strings in a null-safe manner ·
🌐
GitHub
github.com › apache › commons-lang › blob › master › src › main › java › org › apache › commons › lang3 › StringUtils.java
commons-lang/src/main/java/org/apache/commons/lang3/StringUtils.java at master · apache/commons-lang
* StringUtils.getFuzzyDistance("Apache Software Foundation", "asf", Locale.ENGLISH) = 3 ... * @param locale This string matching logic is case-insensitive. A locale is necessary to normalize both Strings to lower case. ... * @throws IllegalArgumentException if either String input {@code null} or Locale input {@code null}. ... * <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/similarity/FuzzyScore.html">
Author   apache
🌐
Apache Commons
commons.apache.org › proper › commons-lang › javadocs › api-3.3 › org › apache › commons › lang3 › StringUtils.html
StringUtils (Apache Commons Lang 3.3 API)
org.apache.commons.lang3.StringUtils · public class StringUtils extends Object · Operations on String that are null safe. IsEmpty/IsBlank - checks if a String contains text · Trim/Strip - removes leading and trailing whitespace · Equals - compares two strings null-safe ·
🌐
Apache Commons
commons.apache.org › proper › commons-lang › javadocs › api-3.7 › org › apache › commons › lang3 › StringUtils.html
StringUtils (Apache Commons Lang 3.7 API)
org.apache.commons.lang3.StringUtils · public class StringUtils extends Object · Operations on String that are null safe. IsEmpty/IsBlank - checks if a String contains text · Trim/Strip - removes leading and trailing whitespace · Equals/Compare - compares two strings null-safe ·
🌐
Baeldung
baeldung.com › home › java › java string › string processing with apache commons lang 3
String Processing with Apache Commons Lang 3 | Baeldung
January 8, 2024 - In addition to providing a general introduction to the library, this tutorial demonstrates methods of the StringUtils class which is used for manipulation of String instances. In order to use the Commons Lang 3 library, just pull it from the central Maven repository using the following dependency: <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.14.0</version> </dependency> You can find the latest version of this library here.
🌐
Apache Commons
commons.apache.org › proper › commons-lang › javadocs › api-3.6 › org › apache › commons › lang3 › StringUtils.html
StringUtils (Apache Commons Lang 3.6 API)
org.apache.commons.lang3.StringUtils · public class StringUtils extends Object · Operations on String that are null safe. IsEmpty/IsBlank - checks if a String contains text · Trim/Strip - removes leading and trailing whitespace · Equals/Compare - compares two strings null-safe ·
🌐
Apache Commons
commons.apache.org › proper › commons-lang › javadocs › api-3.3.2 › org › apache › commons › lang3 › StringUtils.html
StringUtils (Apache Commons Lang 3.3.2 API)
org.apache.commons.lang3.StringUtils · public class StringUtils extends Object · Operations on String that are null safe. IsEmpty/IsBlank - checks if a String contains text · Trim/Strip - removes leading and trailing whitespace · Equals - compares two strings null-safe ·
🌐
Apache Commons
commons.apache.org › proper › commons-lang › javadocs › api-3.1 › org › apache › commons › lang3 › StringUtils.html
StringUtils (Commons Lang 3.1 API)
java.lang.Object org.apache.commons.lang3.StringUtils · public class StringUtils · extends Object · Operations on String that are null safe. IsEmpty/IsBlank - checks if a String contains text · Trim/Strip - removes leading and trailing whitespace · Equals - compares two strings null-safe ·
Find elsewhere
🌐
Apache Commons
commons.apache.org › proper › commons-lang › javadocs › api-release › org › apache › commons › lang3 › StringUtils.html
StringUtils (Apache Commons Lang 3.11 API)
org.apache.commons.lang3.StringUtils · public class StringUtils extends Object · Operations on String that are null safe. IsEmpty/IsBlank - checks if a String contains text · Trim/Strip - removes leading and trailing whitespace · Equals/Compare - compares two strings in a null-safe manner ·
🌐
Maven Repository
mvnrepository.com › artifact › org.apache.commons › commons-lang3
Maven Repository: org.apache.commons » commons-lang3
November 12, 2025 - Home » org.apache.commons » commons-lang3 · Apache Commons Lang, a package of Java utility classes for the classes that are in java.lang's hierarchy, or are considered to be so standard as to justify existence in java.lang. The code is tested using the latest revision of the JDK for supported LTS releases: 8, 11, 17, 21 and 25 currently.
🌐
DZone
dzone.com › data engineering › data › apache commons lang stringutils
Apache Commons Lang StringUtils
May 5, 2012 - StringUtils is part of Apache Commons Lang (http://commons.apache.org/lang/, and as the name suggest it provides some nice utilities for dealing with Strings, going beyond what is offered in java.lang.String.
🌐
Apache Commons
commons.apache.org › proper › commons-lang › javadocs › api-3.4 › org › apache › commons › lang3 › StringUtils.html
StringUtils (Apache Commons Lang 3.4 API)
org.apache.commons.lang3.StringUtils · public class StringUtils extends Object · Operations on String that are null safe. IsEmpty/IsBlank - checks if a String contains text · Trim/Strip - removes leading and trailing whitespace · Equals - compares two strings null-safe ·
🌐
Apache Commons
commons.apache.org › proper › commons-lang › jacoco › org.apache.commons.lang3 › StringUtils.java.html
StringUtils.java - Apache Commons
ArrayUtils.EMPTY_BYTE_ARRAY : string.getBytes(Charsets.toCharsetName(charset)); } /** * Compares all Strings in an array and returns the initial sequence of characters that is common to all of them. * * <p> * For example, {@code getCommonPrefix("i am a machine", "i am a robot") -&gt; "i am a "} * </p> * * <pre> * StringUtils.getCommonPrefix(null) = "" * StringUtils.getCommonPrefix(new String[] {}) = "" * StringUtils.getCommonPrefix(new String[] {"abc"}) = "abc" * StringUtils.getCommonPrefix(new String[] {null, null}) = "" * StringUtils.getCommonPrefix(new String[] {"", ""}) = "" * StringUtils.getCommonPrefix(new String[] {"", null}) = "" * StringUtils.getCommonPrefix(new String[] {"abc", null, null}) = "" * StringUtils.getCommonPrefix(new String[] {null, null, "abc"}) = "" * StringUtils.getCommonPrefix(new String[] {"", "abc"}) = "" *
Top answer
1 of 6
44

I have added commons-lang-2.6.jar & commons-lang3-3.1-sources.jar...

Here's your problem: commons-lang-2.6.jar doesn't contain the org.apache.commons.lang3 package, since that's part of version 3, and commons-lang3-3.1-sources.jar contains the source code, not the byte code.

You need to include commons-lang3-3.1.jar instead.

2 of 6
19

If you're using Maven, put this inside your pom.xml file:

Maven Central Repository for Commons Lang:

Copy<dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    <version>2.6</version>
</dependency>

Maven Central Repository for Apache Commons Lang:

Copy<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
    <version>3.17</version>
</dependency>

Don't forget to Update Maven Project

mvn clean install -U


If you're using Gradle, put this inside your build.gradle file:

Copyimplementation group: 'commons-lang', name: 'commons-lang', version: '2.6'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.17.0'

Gradle (Short)

Copyimplementation 'commons-lang:commons-lang:2.6'
implementation 'org.apache.commons:commons-lang3:3.17.0'

Gradle (Kotlin)

Copyimplementation("commons-lang:commons-lang:2.6")
implementation("org.apache.commons:commons-lang3:3.17.0")

Don't forget to Update Gradle Project

gradle --refresh-dependencies clean build


Apache Commons Lang Dependency Information

Last Published: 29 August 2024 | Version: 3.17

Apache Maven

Copy<dependency>
  <groupId>org.apache.commons</groupId>
  <artifactId>commons-lang3</artifactId>
  <version>3.17.0</version>
</dependency>

Apache Ivy

Copy<dependency org="org.apache.commons" name="commons-lang3" rev="3.17.0">
  <artifact name="commons-lang3" type="jar" />
</dependency>

Groovy Grape

Copy@Grapes(
@Grab(group='org.apache.commons', module='commons-lang3', version='3.17.0')
)

Gradle/Grails

Copyimplementation 'org.apache.commons:commons-lang3:3.17.0'

Scala SBT

libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.17.0"

Leiningen

Copy[org.apache.commons/commons-lang3 "3.17.0"]

Reference:

  • https://commons.apache.org/proper/commons-lang/index.html
  • https://commons.apache.org/proper/commons-lang/dependency-info.html

Maven Central Repository Artifacts:

  • https://mvnrepository.com/artifact/commons-lang/commons-lang
  • https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
🌐
Javadoc.io
javadoc.io › doc › org.apache.commons › commons-lang3 › latest › org › apache › commons › lang3 › StringUtils.html
StringUtils - commons-lang3 3.20.0 javadoc
Latest version of org.apache.commons:commons-lang3 · https://javadoc.io/doc/org.apache.commons/commons-lang3 · Current version 3.20.0 · https://javadoc.io/doc/org.apache.commons/commons-lang3/3.20.0 · package-list path (used for javadoc generation -link option) https://javadoc.io/doc/org.apache.commons/commons-lang3/3.20.0/package-list ·
🌐
Apache Commons
commons.apache.org › proper › commons-lang › apidocs › org › apache › commons › lang3 › Strings.html
Strings (Apache Commons Lang 3.20.0 API)
org.apache.commons.lang3.Strings · public abstract class Strings extends Object · String operations where you choose case-sensitive CS vs. case-insensitive CI through a singleton instance. Since: 3.18.0 · See Also: CharSequenceUtils · StringUtils · Nested Classes ·
🌐
Medium
anas-aboreeda.medium.com › simplifying-java-with-apache-commons-lang-3-practical-examples-5ea1bdb085dd
Simplifying Java with Apache Commons Lang 3 - Practical Examples | by Anas Aboreeda | Medium
February 21, 2024 - import org.apache.commons.lang3.StringUtils; public class StringExamples { public static void main(String[] args) { String str = " Hello World "; // Checking if a string is empty or all whitespace System.out.println("Is it empty? " + StringUtils.isEmpty(str)); // false System.out.println("Is it blank?
🌐
Reddit
reddit.com › r/java › look how they massacred my boy (apache commons lang)
r/java on Reddit: Look how they massacred my boy (Apache Commons Lang)
August 21, 2025 -

Seriously, what madness drove the commons lang contributors to deprecate StringUtils.equals()?

I'm gonna rant for a bit here. It's been a long day.

I spend all morning in an incident call, finally get time to do some coding in the afternoon.

I make progress on a bug fix, clean up some dead code like a good boy scout, and I’m feeling like I actually accomplished something today.

Oh, this service is getting flagged for CVE-2025-48924? Let me take care of that.

And then, confusion. Anger.

Deprecated method? StringUtils.equals()? That can't be.

Sure as shit, they deprecated it. Let's see what has been replaced with.

Strings.CS.equals()? Is that character sequence? No, it's case sensitive. Fucking hell. I harp on juniors for their silly acronyms. Did not expect to see them in a library like this. Just unnecessary. If Java developers had a problem with verbosity, well, they wouldn't be Java developers.

I'll admit I've been an open-source leech, contributing nothing to the community, but this one has lit a fire in me.

If this issue isn't resolved, are there any volunteers to help with a fork? I feel like common-sense-lang3 would be an appropriate name for an alternative.

https://issues.apache.org/jira/projects/LANG/issues/LANG-1777?filter=allopenissues