Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding multiple jars to classpath on commandline [duplicate]

I'm running Ubuntu and want to execute a Java file from terminal by including multiple jar files.

All my jars are included in tha jar folder.

I tried

javac -cp jar/A.jar: jar/B.jar: jar/C.jar: jar/D.jar MyFile.java

I get below error.

javac: invalid flag: jar/B.jar:
Usage: javac <options> <source files>
use -help for a list of possible option

Can anyone guide how to use multiple jars in classpath ?

like image 756
user3044327 Avatar asked Mar 03 '14 19:03

user3044327


1 Answers

Remove the spaces from the classpath and add the current path

javac -cp jar/A.jar:jar/B.jar:jar/C.jar:jar/D.jar:. MyFile.java

Since Java 6 you can use classpath wilcards

javac -cp jar/*:. MyFile.java
like image 60
Reimeus Avatar answered Sep 24 '22 01:09

Reimeus