2

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.

Cœur
  • 32,421
  • 21
  • 173
  • 232
Mubarak Awal
  • 340
  • 3
  • 21

2 Answers2

1

You could use the -cp compiler option.

leftbit
  • 781
  • 1
  • 6
  • 16
1

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
ToYonos
  • 14,576
  • 2
  • 40
  • 62