Including all the jars in a directory within the Java classpath

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

    I have multiple jars in a folder. The below command worked for me in JDK1.8 to include all jars present in the folder. Please note that to include in quotes if you have a space in the classpath

    Windows

    Compiling: javac -classpath "C:\My Jars\sdk\lib\*" c:\programs\MyProgram.java

    Running: java -classpath "C:\My Jars\sdk\lib\*;c:\programs" MyProgram

    Linux

    Compiling: javac -classpath "/home/guestuser/My Jars/sdk/lib/*" MyProgram.java

    Running: java -classpath "/home/guestuser/My Jars/sdk/lib/*:/home/guestuser/programs" MyProgram

提交回复
热议问题