The BASEDIR environment variable is not defined correctly This environment variable is needed to run this program

BASEDIR environment not define error and its solution

Are you working on J2EE with Tomcat?

Trying to run Tomcat from the command line and got this problem?

I got this while working on apache-tomcat 7.

Here is how I solved it.

The basedir environment will complain if you have either the JAVA_HOME and/or the CATALINA_HOME paths are not correctly set on the environment variables.

where to get the environment variable? -> in /etc/environment.
Once you make sure paths are set correctly, the next would be allowing the shell scripts to have the executable permissions.

Basically I would do
sudo chmod 777 -R /PATH/TO/TOMCAT/bin

This, as you know is not advisable if for production or networked environments as it will allow all to execute.

Now, you should be able to startup tomcat as
./startup.sh by going into the tomcat’s bin folder.

Recommended

What is can not access member of class with modifiers and its solution?

Change port in tomcat

See what the no persistence provider error mean for entity manager and how to solve it

Adding Path to Environment in Ubuntu

After adding some software or programing language or whatever to ubuntu, mostly using the non-synaptic method, our command line would crave for the new terms ;).
Here is how to add the new path to the environment
Lets use how to add the tomcat app server after we install it using the tar file.

1. Open the terminal : Application->Accessories->Terminal
2. use your favorite text editor to open /etc/environment in my case I would use view as vi /etc/environment
3. add the path on new line as CATALINA_HOME=”path/to/catalina”
4. save and exit!!
In most cases, the current shell would not see the effect and you may want to open another tab for that or you can use the export command

if we are appending to the existing path variable, we can use the export command as
export PATH = ${PATH}:/path/to/new/location – here the ${PATH} would maintain the existing path information and the colon would be the separator for the paths