1

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 CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
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
Brendon Tsai
  • 111
  • 4
  • Did you have a look at this: http://askubuntu.com/questions/56104/how-can-i-install-sun-oracles-proprietary-java-jdk-6-7-8-or-jre ? – jobin Mar 25 '14 at 08:18

1 Answers1

1

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.

    http://www.oracle.com/technetwork/ja...ads/index.html

  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/libjavaplugin.so mozilla-javaplugin.so /opt/jdk1.7.0_17/jre/lib/amd64/libnpjp2.so 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 mozilla-javaplugin.so /opt/jdk1.7.0_17/jre/lib/amd64/libnpjp2.so
    
  4. Test

    To check the version of Java you are now running

    java -version
    

    To check the browser plugin browse to http://www.java.com/ and click “Do I have Java?”

Danatela
  • 13,243
  • 11
  • 45
  • 72
Vivek
  • 1,380
  • 7
  • 8