Question

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

Was it helpful?

Solution 2

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

OTHER TIPS

In my case, the error was due to the carriage return character being appended to the file where the JAVA_HOME variable was declared making the error harder to track down:

cat -A /etc/environment 

The output:

JAVA_HOME=/usr/java/jdk1.6.0_25^M$
TOMCAT_HOME=/usr/tomcat7^M$
M2_HOME=/usr/maven

The fix:

perl -pi -e "s/\015//g" /etc/environment
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top