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/*" 

(read more)


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -