Including all the jars in a directory within the Java classpath

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

    If you really need to specify all the .jar files dynamically you could use shell scripts, or Apache Ant. There's a commons project called Commons Launcher which basically lets you specify your startup script as an ant build file (if you see what I mean).

    Then, you can specify something like:

    
        
        
        
    
    

    In your launch build file, which will launch your application with the correct classpath.

提交回复
热议问题