1

I am new to ubuntu. I am trying to install java 7 in 14.04 LTS. I have a problem. I will list the activity that I have done. Kindly tell me where I went wrong.

Downloaded jdk-7u80-linux-i586.tar.gz
Created directory jvm in /usr/lib
mv Download/jdk*.gz /usr/lib/jvm
tar -xzvf jdk-7u80-linux-i586.gz
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0_80/bin/java" 0
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0_80/bin/javac" 0
sudo update-alternatives --set java /usr/lib/jvm/jdk1.7.0_80/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/jdk1.7.0_80/bin/javac

added: JAVA_HOME=/usr/lib/jvm/jdk1.7.0_80 PATH=/usr/lib/jvm/jdk1.7.0_80:$PATH in /etc/profileand restarted the system.

When I try to check the installed java I am getting the following problem.

$> which java
/usr/bin/java
$> java
bash: /usr/bin/java: No such file or directory
$> java -version
bash: /usr/bin/java: No such file or directory

Kindly help me in this regard.

KGIII
  • 3,968

1 Answers1

1

I think your problem is on this line:

PATH=/usr/lib/jvm/jdk1.7.0_80:$PATH

You need to add the bin directory to the PATH, because that's where the executables are:

PATH=/usr/lib/jvm/jdk1.7.0_80/bin:$PATH

And since you also defined JAVA_HOME, you could also use it here (to make it easier to read and change):

PATH=$JAVA_HOME/bin:$PATH

And by the way, there's no need to manually download and install, there are simpler ways to do it.

If you just need Java (not necessarily Oracle's Java), you could install OpenJDK:

sudo apt-get update
sudo apt-get install openjdk-7-jdk

If you don't want OpenJDK, and it has to be Oracle, then just do:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

You may also want to have a look about Java in the Ubuntu documentation: https://help.ubuntu.com/community/Java

Cos64
  • 889
  • 1
  • 5
  • 15