importing external jar files
17,943
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 :
).
Author by
Pavithra Gunasekara
Updated on July 22, 2022Comments
-
Pavithra Gunasekara almost 2 years
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!
-
Pavithra Gunasekara over 13 years@ khachik Sorry for the late reply ... Thanx a lot for your advice... I marked your answer as correct... thanx again :-)
-
Daniele over 6 yearsI still get an error: if I invoke
java -cp /usr/share/java/mysql-connector-java-5.1.42.jar Connect
I get the error that Java cannot find theConnect
class. -
HKVariant over 2 years@Daniele 4 years late; but that would mean the Connect.class file is not being found, did you compile first?