I have around hundreds of jars at a particular directory which my application uses. So I thought its hard to add each jars one by one to the classpath. So is there any command or any way so that i can add all the jars at one go. some *.jar should add all the jars.
            Asked
            
        
        
            Active
            
        
            Viewed 2.4k times
        
    25
            
            
        - 
                    An example would be to add "...\java_project\jar\*;" to your classpath. The important part is that after the name of the folder, you include the backslash and the star. – xxjjnn Feb 02 '13 at 17:45
1 Answers
25
            
            
        Yes, you can use a wildcard, as of Java6. See the section on "Understanding class path wildcards"
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. For example, the class path entryfoo/*specifies all JAR files in the directory named foo. A classpath entry consisting simply of*expands to a list of all the jar files in the current directory.
Prior to Java 6, you had to specify them all individually.
- 
                    7That's right, as long as you are using "the CLASSPATH environment variable" or "the -classpath (or -cp) command-line option". The pain starts when using a MANIFEST.MF: "However, class path wildcards are not honored in the Class-Path jar-manifest header." – bobndrew Jun 01 '11 at 11:08
- 
                    
 
     
    