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 did these steps without error:

  1. JDK path : Downloads/jdk-6u37-linux-x64.bin

  2. Commands in Terminal :

           mkdir Programs
           cd Programs
           bash ../Downloads/jdk-6u37-linux-x64.bin
           ln -s jdk-6u37-linux-x64 jdk
  3. Set JAVA_HOME and Path: in Home ->View Menu ->Show Hidden Files. Then open .bashrc in text editor. I added the following lines to end of file.

    export JAVA_HOME=$Home/Programs/jdk
    export PATH=:$JAVA_HOME/bin:$PATH

This is the result of executing the command

echo $JAVA_HOME :

This is the result of executing the command

echo $PATH :

And problem is : This is the result of executing the command java -version :

The program 'java' can be found in the following packages:
 * default-jre
 * gcj-4.6-jre-headless
 * gcj-4.7-jre-headless
 * openjdk-7-jre-headless
 * openjdk-6-jre-headless
Try: sudo apt-get install 
share|improve this question
up vote 1 down vote accepted
export JAVA_HOME=$Home/Programs/jdk

You should use $HOME as $Home is undefined.


export JAVA_HOME=$HOME/Programs/jdk
share|improve this answer
Thanks. ‌But Why is this form ? My home folder is exactly Home, not HOME. – HFDev Nov 9 '12 at 13:39
$HOME is the environment variable representing your home directory, not the directory itself. – HFDev Dec 2 '12 at 23:23

You need to use update-alternatives to update the soft links determining commands.

for example:

    sudo update-alternatives --install "/usr/bin/java" "java" "/opt/jdk1.6.0_37/bin/java" 1
    sudo update-alternatives --install "/usr/bin/java" "java" "/opt/jdk1.6.0_37/jre/bin/java" 2

In your case, it's $Home/Programs/jdk instead of /opt/jdk1.6.0_37

Note If updating from a previous version that was removed manually, execute the above command twice, because you'll get an error message the first time.

Then set the new JRE as the default:

    sudo update-alternatives --set java /opt/java/jdk1.6.0_37/bin/java


    sudo update-alternatives --config java


root@ubuntu:/opt# update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
  0            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      auto mode
* 1            /opt/jdk1.6.0_37/bin/java                        1         manual mode
  2            /opt/jdk1.6.0_37/jre/bin/java                    2         manual mode
  3            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode

run java -version to confirm java version

NOTE: I recommend using the oab-java bash script on Github.

share|improve this answer

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.