Ubuntu – Why I can’t use the CATALINA_HOME environment variable

bashcommand lineenvironment-variablesservertomcat

I am not yet a Linux guy and I have the following problem with environment variable.

So I want to add a permanent environment variable and I do in this way:

I open the /etc/profile file and I add this line at the end of this file:

CATALINA_HOME=/opt/apache-tomcat-8.0.24

Where /opt/apache-tomcat-8.0.24 is the folder that contain the tomcat installation (it contains the bin TomCat subfolder)

Then I save this file.

So I close the shell and I reopen it and I try to do:

andrea@andrea-virtual-machine:/$ sudo ./startup.sh
sudo: ./startup.sh: command not found

To start the server instead enter into /opt/apache-tomcat-8.0.24/bin/ and perform the command.

But as you can see I obtain an error. What am I missing?

Best Answer

sudo ./startup.sh command will execute the startup.sh script in your current directory.

This you should do:

Add this line to /etc/profile for setting path while booting( Permanent change)

export CATALINA_HOME=/opt/apache-tomcat-8.0.24

To set path temporarily execute above command in the current shell.

and excute this:

sudo $CATALINA_HOME/bin/startup.sh
Related Question