Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java how to add a library or API while compiling with command line?

The question says it all, I am trying to use an external library in my code, but it tells me that the packages I referenced to don't exist so I'm guessing the imports don't work. How do I do this?

like image 750
Zach Sugano Avatar asked Jun 07 '26 01:06

Zach Sugano


1 Answers

Use the -cp option as described in the javac notes.

Specify where to find user class files, and (optionally) annotation processors and source files. This class path overrides the user class path in the CLASSPATH environment variable. If neither CLASSPATH, -cp nor -classpath is specified, the user class path consists of the current directory. ..

like image 118
Andrew Thompson Avatar answered Jun 09 '26 14:06

Andrew Thompson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!