Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to install jdk-6 in ubuntu 12.04. I put the folder in /opt and set the environment path:

vim /etc/profile
vim /etc/bash.bashrc

add this to both of the files:

#set java environment
export JAVA_HOME=/opt/jdk1.6.0_37
export JRE_HOME=/opt/jdk1.6.0_37/jre
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

I change the user status to root userso I have the authority to edit the file. After that, I use java -version to check the result, it works fine in root user status:

root@brendon-Lenovo:/home/brendon# java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

But when I change back to normal user, I can't find the jdk I've installed:

brendon@brendon-Lenovo:~$ java -version
程序 'java' 已包含在下列软件包中:
 * default-jre
 * gcj-4.6-jre-headless
 * openjdk-6-jre-headless
 * gcj-4.5-jre-headless
 * openjdk-7-jre-headless

I check the profile and bash.bashrc, both of them are modified, so I really have no idea why can't I use jdk-6 in my normal status.

Does anyone know why?

I have tried

sudo chmod -R 755 /opt/[java folder name]
sudo chown -R [username] /opt/[java folder name]

Then I check the java -version, anyway, it doesn't work.

The program 'java' can be found in the following packages:
 * default-jre
 * gcj-4.6-jre-headless
 * openjdk-6-jre-headless
 * gcj-4.5-jre-headless
 * openjdk-7-jre-headless
share|improve this question
Did you have a look at this:… ? – i08in Mar 25 '14 at 8:18

It's probably because you don't have access to /opt/java folder as normal user. Try below commands and then try to access:

sudo chmod -R 755 /opt/[java folder name]
sudo chown -R [username] /opt/[java folder name]

In case you are willing to try another method. I use it and it works all the time.

  1. Download the latest Java SE SDK version.

  2. Untar the Archive

    tar -xzvf /root/jdk-7u17-linux-x64.tar.gz
    mv jdk1.7.0_17 /opt
    cd /opt/jdk1.7.0_17
  3. This step registers the downloaded version of Java as an alternative, and switches it to be used as the default:

    update-alternatives --install /usr/bin/java java /opt/jdk1.7.0_17/bin/java 1
    update-alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_17/bin/javac 1
    update-alternatives --install /usr/lib/mozilla/plugins/ /opt/jdk1.7.0_17/jre/lib/amd64/ 1
    update-alternatives --set java /opt/jdk1.7.0_17/bin/java
    update-alternatives --set javac /opt/jdk1.7.0_17/bin/javac
    update-alternatives --set /opt/jdk1.7.0_17/jre/lib/amd64/
  4. Test

    To check the version of Java you are now running

    java -version

    To check the browser plugin browse to and click “Do I have Java?”

share|improve this answer
Thanks, but that doesn't work. – Brendon Tsai Mar 25 '14 at 7:53
I have edited the answer above in case you are willing to try another way of installing java. – Vivek Mar 25 '14 at 8:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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