Java Language The Classpath Adding all JARs in a directory to the classpath

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!


If you want to add all the JARs in directory to the classpath, you can do this concisely using classpath wildcard syntax; for example:


This tells the JVM to add all JAR and ZIP files in the someFolder directory to the classpath. This syntax can be used in a -cp argument, a CLASSPATH environment variable, or a Class-Path attribute in an executable JAR file's manifest file.See Setting the Class Path: Class Path Wild Cards for examples and caveats.


  1. Classpath wildcards were first introduced in Java 6. Earlier versions of Java do not treat "*" as a wildcard.
  2. You cannot put other characters before or after the ""; e.g. "someFolder/.jar" is not a wildcard.
  3. A wildcard matches only files with the suffix ".jar" or ".JAR". ZIP files are ignored, as are JAR files with a different suffixes.
  4. A wildcard matches only JAR files in the directory itself, not in its subdirectories.
  5. When a group of JAR files is matched by a wildcard entry, their relative order on the classpath is not specified.

Got any Java Language Question?