Over a million developers have joined DZone.

Java: Run Java Application With Classpath Set To The Folder With Jars

Consider class my.mackage.Main is packed in some jar in 'target' folder, and dependencies are in target/dependencies. Then run the app like this:

java -cp "target\*;target\dependency\*" my.package.Main

Consider that class Main is in current folder and dependencies are in 'lib' folder. Then run the app like this:

java -cp ".;lib\*" Main

Note, there is no *.jar and -cp parameter is double-quoted

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}