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.
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.
StringUtils is an Apache Commons project. You need to download and add the library to your classpath.
To use:
import org.apache.commons.lang3.StringUtils;
Edited 07.12.2018:
I think dependency for StringUtils you are using is not proper.
Please add below dependency to gradle and Sync project and import your class.
implementation 'org.apache.commons:commons-lang3:3.6'
This on is using deprecated task (but should still works):
compile 'org.apache.commons:commons-lang3:3.5'
Edit:
As OoDeLally mentioned in a comment,
Above mentioned version is deprecated, Please use below dependency:
implementation 'org.apache.commons:commons-text:1.9'
Edit 2:
deprecated as for July 2019. Use stackoverflow.com/a/55567755/1541141 instead
Thanks @OoDeLally!
for StringUtils you need to add in app.gradle
implementation 'org.apache.commons:commons-text:1.7'
Check your version of commons-lang, mine was version 2.6 used sudo find / | grep commons-lang
add to the dependencies before plugins and ensure id starts with I not i:
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
Does not build as per wiki there is no controller/opendaylight/distribution/opendaylight/target in order to ./run.sh So I am looking for that now ??
Since OP did not specify details I guess this may be about running maven on Ubuntu 14.
Maven packaging on Ubuntu seems to have some "issue".
After apt-get install maven in Ubuntu 14.04.1 LTS and attempting to package my project with mvn package I got the same exception.
Workaround from comment on github is:
sudo ln -s ../../java/commons-lang.jar /usr/share/maven/lib
That fixed maven at least in my case.
Try running the following commands and examine the output:
$ mvn dependency:tree
$ mvn help:effective-pom
Look for commons-lang, maybe something will draw your attention like excludes or dependency overrides. Also, is:
$ mvn dependency:copy-dependencies
copying commons-lang JAR to your target?
Adding following dependency to pom.xml in dependencies tag helped me:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
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.
If you're using Maven, put this inside your pom.xml file:
Maven Central Repository for Commons Lang:
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
Maven Central Repository for Apache Commons Lang:
<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:
implementation group: 'commons-lang', name: 'commons-lang', version: '2.6'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.17.0'
Gradle (Short)
implementation 'commons-lang:commons-lang:2.6'
implementation 'org.apache.commons:commons-lang3:3.17.0'
Gradle (Kotlin)
implementation("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
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.17.0</version>
</dependency>
Apache Ivy
<dependency org="org.apache.commons" name="commons-lang3" rev="3.17.0">
<artifact name="commons-lang3" type="jar" />
</dependency>
Groovy Grape
@Grapes(
@Grab(group='org.apache.commons', module='commons-lang3', version='3.17.0')
)
Gradle/Grails
implementation 'org.apache.commons:commons-lang3:3.17.0'
Scala SBT
libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.17.0"
Leiningen
[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