I'm trying create environment variable in tomcat 8 for my project, I need use this variable for choice properties logger. I read about setenv.sh
and i create this file, but when i run my project - it does not run. How me create environment variable for check my project?
I read about setenv
in this site. I use ubuntu 14.04.
setenv.sh
JAVA_HOME="/usr/lib/jvm/java-8-oracle"
export JAVA_HOME
JAVA_OPTS="-Xmx4096m -Xms512m -server"
export JAVA_OPTS
CATALINA_HOME="/opt/tomcat"
export CATALINA_HOME
Apart from CATALINA_HOME and CATALINA_BASE, all environment variables can be specified in the "setenv" script. The script is placed either into CATALINA_BASE/bin or into CATALINA_HOME/bin directory and is named setenv. bat (on Windows) or setenv.sh (on *nix). The file has to be readable.
You can set your own variables at the command line per session, or make them permanent by placing them into the ~/. bashrc file, ~/. profile , or whichever startup file you use for your default shell. On the command line, enter your environment variable and its value as you did earlier when changing the PATH variable.
Please do the following. It'll work for you.
1 sudo su and cd to /var/lib/tomcat8/bin/
2 touch setenv.sh(if it doesn't exist)
3 chmod 777 setenv.sh
4 vim setenv.sh and set following line in setenv.sh
export varriable=value
5 sudo service tomcat8 restart
and Enjoy...!!
Rather than create /usr/share/tomcat8/bin/setenv.sh
, you can put those settings in /etc/default/tomcat8
.
I've found that setting JAVA_HOME in setenv.sh causes tomcat8 to not start up properly if it doesn't match what /etc/init.d/tomcat8
comes up with. The init.d script ignores setenv.sh but needs to know which java version is used so that it can check the process list to see if tomcat is running. The init.d script does use /etc/default/tomcat8
, so it makes sense to delete setenv.sh and just put the settings in /etc/default
.
There is an alternate way if we're using eclipse:
Servers
tabOpen launch configuration
Environment
tabNew
and set the key-value pair of environment variablesIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With