I am new to programming, I wanted to download and setup Apache Tomcat on my Ubuntu. I copied the tar link from Apache. I then decompressed the file with

tar xvzf Apache-tomcat.7.0.94.tar.gz

Now I'm following a set of instruction as below

  • Set the environment variables in .bashrc with the following command:
    vim ~/.bashrc
  • Add this information to the end of the file:
    export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
    export CATALINA_HOME=/opt/tomcat/apache-tomcat-8.5.32 

My problem is if use vim ~/.bashrc it won't open.

  • 5
    What happens when you type the command? – user833907 Jul 18 '19 at 7:33
  • Two questions: 1. Do you have vim installed? 2. Do you know how to use it since it doesn't behave like the traditional text editors. If you're using Ubuntu, you could try replacing vim with gedit (which comes installed with the distribution) and try again e.g. gedit ~/.bashrc – haralambov Jul 18 '19 at 7:39
  • Try the simple vi, then nano. In case "~/.bashrc won't open" there should be an error message you'd quote in the original question! – EnzoR Jul 18 '19 at 7:44
  • or try a simple redirected echo to tee -a : echo -e "export VAR1=/foo/bar\nexport VAR2=/rab/oof" | tee -a ~/.bashrc – cmak.fr Jul 18 '19 at 7:53

Using vim as an editor is a bit confusing. So, I suggest you use another text editor like gedit or nano.
The command will be as follows:

gedit ~/.bashrc

The file will be opened, go to the end of the file and add the following lines:

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
export CATALINA_HOME=/opt/tomcat/apache-tomcat-8.5.32

After that save (using Ctrl + s or by pressing the save buttoon on the top right of the editor) and exit.

Or simply, you can run the following command (as mentioned cmak.fr):

echo -e "export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64" >> ~/.bashrc 

Then another one for the second line:

echo -e "export CATALINA_HOME=/opt/tomcat/apache-tomcat-8.5.32" >> ~/.bashrc

If you have some issue with privileges you can run the previous commands with sudo:

echo -e "export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64" >>  ~/.bashrc  
echo -e "export CATALINA_HOME=/opt/tomcat/apache-tomcat-8.5.32" >> ~/.bashrc

Simplest way? Just append the desired lines to the desired file:

echo export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 >> ${HOME}/.bashrc
echo export CATALINA_HOME=/opt/tomcat/apache-tomcat-8.5.32 >> ${HOME}/.bashrc

Now, you should investigate why vim doesn't work on that file. Check the permissions and ownership of .bashrc. That would be a typical symptom of the problem you are seeing.

Can you give us the output of:

whoami ; ls -la ${HOME}/.bashrc
  • I believe, by default only vim.tiny is installed, that's why vim doesn't work. – mook765 Jul 18 '19 at 9:56
  • What makes you think that? vim-tiny usually works just fine, at least in my experience. While I have the full vim installed, I can still invoke vim-tiny by invoking vim.tiny. It complains about my .vimrc having syntax on, but apart from that I can just edit my .bashrc fine. vim-tiny is vim without a set of features, but the part where you can edit files is actually still there. – jawtheshark Jul 18 '19 at 10:08
  • You might mean that the vim command is not working. I doubt that. That is handled by /etc/alternatives and it's symlinks to the actual binary. – jawtheshark Jul 18 '19 at 10:10
  • Yes, vim.tiny works fine, but vim leads to command not found. I see in my (pretty vanilla installation) that vim.tiny is installed but vim not. – mook765 Jul 18 '19 at 10:14
  • Hmmm, alas I have no machines to test without vim.basic. What does your update-alternatives --display vim say? – jawtheshark Jul 18 '19 at 10:16

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.