简体   繁体   中英

How to use Apache Commons Lang code without an IDE? (org.apache.commons.lang3)

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.xml file 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.java and when you run: java -cp commons-lang3-3.11.jar:. Foo java -cp commons-lang3-3.11.jar:. Foo

The files you see in your working directory should be Foo.java and commons-lang3-3.11.jar . After you have run javac you will also see Foo.class .

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