Java command line with external .jar

Concatenate each jar file argument to cp with:

; on Windows
: on Linux or Mac

e.g.

java -cp <path>\TOOLS.jar;.;<path>\jar2.jar;<path>\jar3.jar HelloWorld

on newer JVMs (6+, I think) you can also use the * to append all JARs in a directory e.g.

java -cp .;<path>\*; HelloWorld

To go a step further and create a single packaged executable see this question.

Leave a Comment