I am using Amazon Coretto, a JDK, to write and run Java code. I am trying to use a class from Apache Commons Lang with simple import statements like:
import org.apache.commons.lang3.*
However, everything I have looked up online will only describe how to do this with an IDE like Eclipse. How do I download the org.apache.commons.lang3 class and use its subclasses with only a JDK?
The best way to do this is to install Maven, create a
pom.xmlfile and add commons-lang as a dependency.The minimal way is to download from https://repo1.maven.org/maven2/org/apache/commons/commons-lang3/3.11/commons-lang3-3.11.jar and add the jar to your class path when you compile:
javac -cp commons-lang3-3.11.jar Foo.javaand when you run:java -cp commons-lang3-3.11.jar:. FooThe files you see in your working directory should be
Foo.javaandcommons-lang3-3.11.jar. After you have runjavacyou will also seeFoo.class.