How create environment variable for tomcat?

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 
3

3 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...!!

0

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:

  1. Go to Servers tab
  2. Double click on the server
  3. Click Open launch configuration
  4. Go to Environment tab
  5. Click New and set the key-value pair of environment variables

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like