Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 
share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted
export JAVA_HOME=$Home/Programs/jdk

You should use $HOME as $Home is undefined.

e.g.

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
1  
$HOME is the environment variable representing your home directory, not the directory itself. –  HFDev Dec 2 '12 at 23:23
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

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.