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 ?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With