Search code examples
ubuntujava-home

JAVA_HOME is not defined correctly


I'm very new to Ubuntu, so I would appreciate some help.

I am installing Apache ActiveMQ, and for this I need maven to be installed. First I installed jdk and jre java packages, and edited /etc/profile like the following:

JAVA_HOME=/usr/local/java/jdk1.7.0_09 
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin 
JRE_HOME=/usr/local/java/jre1.7.0_09 
PATH=$PATH:$HOME/bin:$JRE_HOME/bin 
export JAVA_HOME 
export JRE_HOME 
export PATH

but when I installed maven, and it gave me JAVA_HOME is not defined correctly. So after a small research, I edited /etc/bash.bashrc and included the following:

JAVA_HOME=/usr/local/java/jdk1.7.0_09 
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin 
export PATH 

And now it displays:

Error: JAVA_HOME is not defined correctly.
  We cannot execute /usr/local/java/jdk1.7.0_0.9/bin/java/bin/java

I'm sure my mistake is trivial, but it's the first time I use ubuntu So I couldn't figure it out... I appreciate any help


Solution

  • It's clearly mentioning we cannot execute /usr/local/java/jdk1.7.0_0.9/bin/java/bin/java

    This path indeed doesn't exist. If you have downloaded zip distribution of JDK 1.7 point your path to extracted Java folder bin directory.

    If you are already able to run java from bash, just type which java, that should print the installed folder