Linux – Create setenv.sh to set system property

javalinuxshelltomcat

I have to use setenv.sh to set system properties on Linux with Tomcat Server 6.

As described here Linux Environment- setenv.sh, I have created a setenv.sh in tomcat/bin, and the only think I added is the

export JAVA_OPTS =”-Dmyprojectvar.subname=value -Danothervariable=value -Danother.variable=value”

I don't know, is this enough to set the properties. I just want to add three properties to tomcat as system property using setenv.sh. What should I do to complete it successfully? What are the steps for it?

I saw this question setenv.sh is not working. No is answer given there and I don't understand the question. Do we need to set CATALINA_HOME and other properties somewhere in setenv.sh?.

Best Answer

It looks like the problem you have is magic quotes, note that (U+201D : RIGHT DOUBLE QUOTATION MARK) is not the same as " (U+0022 : QUOTATION MARK), the former will cause your shell script to fail (this is a prblem you need to watch out for when copying from people's blogs) e.g.

setenv.sh: line 1: export: `-Danothervariable=value': not a valid identifier

setenv.sh: line 1: export: `-Danother.variable=value”': not a valid identifier

Try this which used "

export JAVA_OPTS="-Dmyprojectvar.subname=value -Danothervariable=value -Danother.variable=value"

I just noticed you have a space between = and " that shouldn't be there either.