Not recognize JDK after installation in ubuntu 12.10

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 :
/Programs/jdk

This is the result of executing the command

echo $PATH :
:/Programs/jdk/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games1

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 

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

or

    sudo update-alternatives --config java

Example:

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.

https://github.com/flexiondotorg/oab-java6


export JAVA_HOME=$Home/Programs/jdk

You should use $HOME as $Home is undefined.

e.g.

export JAVA_HOME=$HOME/Programs/jdk