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 33 Answers
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...!!
0Rather 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:
- Go to
Serverstab - Double click on the server
- Click
Open launch configuration - Go to
Environmenttab - Click
Newand set the key-value pair of environment variables