Browniez Browniez - 3 months ago 22
Java Question

Compiling multiple .jar files with .java class

I currently have a java class which I am attempting to compile using Linux terminal along with a folder (/libs) which contains about 9 .jar folders.
I am struggling trying to attempt this.
I am aware of how to compile a single library to a class:

javac -classpath /libs/example.jar MyMainClass.java


just unsure of how this can apply to multiple libraries.

Thanks.

Answer

You can either refer to an entire folder containing all the libraries such as javac -cp lib\* MyMainClass.java

Alternatively, you can refer individual libraries as such: javac -cp lib1\Library.jar;lib2\Library.jar MyMainClass.java (separate with semicolon)