Including all the jars in a directory within the Java classpath

前端 未结 24 3606
鱼传尺愫
鱼传尺愫 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:18

    If you are using Java 6, then you can use wildcards in the classpath.

    Now it is possible to use wildcards in classpath definition:

    javac -cp libs/* -verbose -encoding UTF-8 src/mypackage/*.java  -d build/classes
    

    Ref: http://www.rekk.de/bloggy/2008/add-all-jars-in-a-directory-to-classpath-with-java-se-6-using-wildcards/

提交回复
热议问题