Adding JAR to CLASSPATH in Mac OS

前端 未结 1 1498
别跟我提以往
别跟我提以往 2021-02-09 18:09

I am trying to set up the CLASSPATH for Java under Mac OS.

Specifically I am trying to add a couple of JAR archives to it.

If I do it like:

## Se         


        
相关标签:
1条回答
  • You must set the jars on the classpath individually. There are ways around this though. One that I use is starting the java app with a shell script that contains something like this:

     cd $JAR_DIR
     jars=($(ls *.jar))
     JAR_PATH=""
     dir=$(pwd)
     for i in "${jars[@]}"; do
        JAR_PATH="${JAR_PATH}:$dir/$i"
     done
     CLASSPATH=$CLASSPATH:$JAR_PATH
    

    This will work.

    0 讨论(0)
提交回复
热议问题