If you have installed Tomcat from a package and it is running as a service you will have to go to the directory where your init scripts are located and edit your tomcat init script.In the case of Debian squeeze the script is /etc/init.d/tomcat6 but your path and script name might be different.You should first stop tomcat by executing the script with the stop argument.
One important thing, before editing anything make sure you create a backup copy of the script or file you will be editing!!!!
Just find the CATALINA_BASE and CATALINA_HOME variable definitions and modify them to point where your want them.Keep in mind that shell variables commit the $ at the start of the name when defined.
After that move the contents of the old dirs to the new locations cp -Rp * /path/to/destination/dir should do that nicely I think, the trick here is to preserve the ownership and permissions of the stuff while copying it.Also make sure that your new directories have the same ownership and permissions as the old ones, you will also have to create the destinations if they do not exist.I of more information check the man pages for cp and chown.
If you are using a customized setup w/o a setup script you will just have to set those variables for the user under which Tomcat will be running, iirc there was a setenv script that came with Tomcat, that you could edit.Check the Tomcat documentation regarding it.
A user's environmental variables will have to be set in either his .bashrc or .profile file they also have to be exported:
export VARNAME='value' should work.
Then switch to the user and execute echo $VARNAME to check if it is set properly, however that will only work of you are starting it manually without an init script.My advice, if you are using some type of custom setup, Tomcat is starting OK at startup, and you can't locate the script by name go into your distro's equivalent to/etc/init.d and do grep CATALINA * that will get you the file you need.
Some more info about your setup and distro name as well as why you are doing what you are doing will be good.
Last edited by vl23; 02-05-2013 at 01:23 PM.