Here is my suggestion
How to compile and use the .jar extension
Expansion
.jar can be imported in various ways, depending on the development environment.
Here it works as the main mode from the console.
- Download the
.jar.zip library from
http://www.java2s.com/Code/Jar/c/Downloadcommonslang333jar.htm
- Create a folder in your working (project) directory, call it
libs - Unzip the downloaded file and copy
commons-lang3-3.3.jar to the libs working directory - I also created a class just for testing, name it
TheNewWork.java and add 3 imports. Now from your working directory c:\projects to compile:
javac -classpath "/Projects/libs/commons-lang3-3.3.jar;" TheNewWork.java
And to run:
java -classpath "/Projects/libs/commons-lang3-3.3.jar;" TheNewWork
If you have more than one .jar , just add ; for Windows and : for Linux. Btw I am using the Windows 10 cmder console and java jdk1.8.0_66. In another OS console, you may need to install .:Projects...etc instead of /Projects...etc . but the idea is the same.
UPDATE
In windows, you can set the class path, for example
set CLASSPATH=%CLASSPATH%;C:\Projects\libs\commons-lang3-3.3.jar
OR on Linux
export CLASSPATH=".:/Projects/libs/commons-lang3-3.3.jar"
Then you can run javac TheNewWork.java , but it's a personal desire to do it anyway. Some similar things can be done in other OSs.
Last, if you are lazy and donβt want to write a full command line or not create a class path, you can create a batch file with a full command line and run it this way :;
Some links:
Hope this solves your problem.
Until decision 
After decision 
NOTE
In addition, thanks to @MarkPeters, he notified me of my previous answer: adding application dependencies directly to JRE libs is not a good approach, since JRE is suitable for running only one Java application, and not for general runtime. Plus, this will complicate any deployment that the OP wants to do. lib / ext is designed to extend the core Java APIs as described here: docs.oracle.com/javase/tutorial/ext/basics/install.html . Not for normal application dependencies.
source share