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

vb.net - Alternative to the T-SQL AS keyword -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

ios - CFRelease causing crash in iPad application -