How to set multiple jars in java classpath?

Is it possible to include multiple jars in java classpath? If so, can someone please explain?


  • Please check this thread.

  • Wild cards were introduced from Java 6. Class path entries can contain the basename wildcard character *, which is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR.

    java -cp "lib/*" -jar %MAINJAR%

    If you need only specific jars, you will need to add them individually. The classpath string does not accept generic wildcards like Jar*, .jar, hiber etc.


    The following entry does not work:

    java -cp "Halo.jar;lib/*.jar" ni.package.MainClass

    Correct entry is :

    java -cp "Halo.jar;lib/*" ni.package.MainClass

    More about....Java Classpath


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!