Using WildCards for Resolving Classpath

In this post we shall learn using wildcards for resolving classpath, this is an interesting topic and very useful in case you are pro command line or non-GUI user.

I hope we are all familiar with running a Java Program from Command Line using java command.

Whenever the above Class TestMain.java needs additional dependent jars you have to manually list each jar on your Classpath such as:

From Java versions 1.6 onwards a little known feature is that we can now use wildcards, so the above command becomes:

 

I hope this has been useful for you and I’d like to thank you for reading. If you like this article, please leave a helpful comment and share it with your friends.

Leave a Reply

Your email address will not be published. Required fields are marked *