java - strange behaviour : export CLASSPATH=$(JARS=(./lib/*.jar); IFS=:; echo "${JARS[*]}") -
export classpath=$(jars=(./lib/*.jar); ifs=:; echo "${jars[*]}") if put line in bash_script.sh ,
chmod +x bash_script.sh and run
./bash_script.sh it gives error.
syntax error: "(" unexpected (expecting ")") how ever able run thing directly prompt , expected result. as
$ export classpath=$(jars=(./lib/*.jar); ifs=:; echo "${jars[*]}") i wondering reason strange behaviour.
make sure have #!/bin/bash @ top of shell script. array syntax var=(...) bash-ism. won't work in plain sh (#!/bin/sh).
by way, looks line my answer here. if so, encourage use updated solution rather this.
there's no need manually build classpath list. java supports convenient wildcard syntax directories containing jar files.
java -cp "$lib/*"
Comments
Post a Comment