Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add jar files to java project without gradle or Maven or Eclipse

Can I add a jar file to a Java project I created on my desktop manually without using gradle, Maven or any dependency management tool or any Java IDE? Currently the project is a single folder containing 5 java files and I run it from the terminal. Is it possible to use a jar dependency in this kind of project. If Yes, please show me how.

like image 230
Mubarak Awal Avatar asked Sep 14 '25 00:09

Mubarak Awal


2 Answers

Look at this answer

Supposing you have in the root directory of your project a Test.jar and a lib directory containing jar files :

Windows

java -cp "Test.jar;lib/*" my.package.MainClass

Unix

java -cp "Test.jar:lib/*" my.package.MainClass
like image 128
ToYonos Avatar answered Sep 16 '25 13:09

ToYonos


You could use the -cp compiler option.

like image 33
leftbit Avatar answered Sep 16 '25 13:09

leftbit