Windows/linux under the reference jar package, and Javac/java compiled to run, the need for friends can refer to the next.
1> Windows
Suppose the jar to be referenced is placed in the D:/test directory with the name T1.jar, and the Java source file is placed in the D:/TEST/SRC directory with the name T2.java.
Compile:
JAVAC-CP D:/test/t1.jar D:/test/src/t2.java
Run:
JAVA-CP D:/TEST/T1.JAR;D:/TEST/SRC T2
Note that there is no space behind the semicolon, or an error.
It is important to note that if the Java source file is a package, such as the package is com.example, the source file is Com.example.t2.java.
For example, the file storage directory is: D:/test/src/com/example/t2.java, and then for example T1.jar placed under d:/test/lib/, then Javac compile time in the d:/test/directory.
You can specify the build location of the. Class with the-D option.
JAVAC-CP d:/test/lib/t1.jar;classes;. -D Classes Src/com/example/t2.java
2> Linux
Assuming that the jar package is placed in the/home/bill directory, the name T1.jar,java source file is placed in the/HOME/BILL/SRC directory with the name T2.java
Compile:
Javac-cp/home/bill/t1.jar/home/bill/src/t2.java
If you are referencing multiple jars, separate them with colons.
Run:
java-cp/home/bill/t1.jar:/home/bill/src T2
Note that this is a colon delimiter, and there are no spaces behind it.
Windows/linux the jar package and run it with Javac/java compilation