Including all the jars in a directory within the Java classpath

前端 未结 24 4398
鱼传尺愫
鱼传尺愫 2020-11-21 04:25

Is there a way to include all the jar files within a directory in the classpath?

I\'m trying java -classpath lib/*.jar:. my.package.Program and it is no

24条回答
  •  孤城傲影
    2020-11-21 05:13

    Under windows this works:

    java -cp "Test.jar;lib/*" my.package.MainClass
    

    and this does not work:

    java -cp "Test.jar;lib/*.jar" my.package.MainClass
    

    notice the *.jar, so the * wildcard should be used alone.


    On Linux, the following works:

    java -cp "Test.jar:lib/*" my.package.MainClass
    

    The separators are colons instead of semicolons.

提交回复
热议问题