3

I installed Java JDK on Ubuntu 12.04 and added Java home to my path at ~/.bashrc:

export PATH=/opt/jdk1.7.0_40/jdk1.7.0_40/bin:$PATH

This looks a little bit strange but it's really my path.

After this I installed maven through:

sudo apt-get install maven

It installed all the needed libraries and now when I run mvn -version, I see:

Error: JAVA_HOME is not defined correctly.  
We cannot execute /opt/jdk1.7.0_40/bin/java

What is wrong with it?

  • How to solve this trouble?
kiri
  • 27,676
  • 16
  • 81
  • 117
catch23
  • 1,224
  • 9
  • 31
  • 42

3 Answers3

3

You should add these lines to your ~/.pam_environment file instead (create it if it doesn't exist)

PATH DEFAULT=${PATH}:/opt/jdk1.7.0_40/jdk1.7.0_40/bin
JAVA_HOME DEFAULT=/opt/jdk1.7.0_40/jdk1.7.0_40

More information (read this)

Using .bashrc is not recommended at the above link.

kiri
  • 27,676
  • 16
  • 81
  • 117
0

add to your .bashrc this command:

export JAVA_HOME=/opt/jdk1.7.0_40/jdk1.7.0_40
Hakeem Wahab
  • 625
  • 4
  • 11
0

Had same error message and after install of debian 1.6 jdk the file in /usr/lib/jvm/java-6-openjdk-i386/bin/java was a symbolic link to ../jre/bin/java, which was not set executable, fixed with:

chmod 755 /usr/lib/jvm/java-6-openjdk-i386/bin/../jre/bin/java

and without changing JAVA_HOME, or anything else, it worked.

Wiley
  • 1