Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

importing external jar files

I have written a Java code which imports an external jar file. How can I compile and run it on the command-line?

Thanks in advance!

like image 670
Pavithra Gunasekara Avatar asked Dec 12 '10 12:12

Pavithra Gunasekara


1 Answers

Compiling from the command-line:

javac -cp path_to_jar1.jar:path_to_jar2.jar Example.java

Running:

java -cp .:path_to_jar1.jar:path_to_jar2.jar Example

For Windows, use ; as a path-separator (instead of :).

like image 61
khachik Avatar answered Sep 23 '22 04:09

khachik