Including all the jars in a directory within the Java classpath

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

    My solution on Ubuntu 10.04 using java-sun 1.6.0_24 having all jars in "lib" directory:

    java -cp .:lib/* my.main.Class

    If this fails, the following command should work (prints out all *.jars in lib directory to the classpath param)

    java -cp $(for i in lib/*.jar ; do echo -n $i: ; done). my.main.Class

提交回复
热议问题