Installing Sun JAVA in Ubuntu
Step by step:
- Download JDK from Sun/Oracle. Choose bin version (not rpm). The file would be in form of jdk-version-platform.bin (in my case it was: jdk-6u25-linux-x64.bin )
- Add execution rights to the downloaded file
$ chmod u+x jdk-6u25-linux-x64.bin - Execute script. It will unpack its content to current directory (press Enter when asked)
$ ./jdk-6u25-linux-x64.bin
Now you should have directory i.e. jdk1.6.0_25/ with JDK files in it. - Move unpacked JDK to final destination e.g. /opt/java/
$ sudo mv jdk1.6.0_25/ /opt/java/ - Create symbolic link to that directory that will represent this JDK in general regardless current version. It will ease the future updates of JDK. I can any name. I have chosen sun-java6-manual
$ cd /opt/java/
$ sudo ln -s jdk1.6.0_25 sun-java6-manual - Now create another symbolic link in /usr/lib/jvm pointing to previous one.
$ cd /usr/lib/jvm/
$ sudo ln -s /opt/java/sun-java6-manual - I assume that you have already installed Sun JDK from Ubuntu repositories before. If this is the case then there should be .java-6-sun.jinfo file in/usr/lib/jvm/ directory. We will copy that file and modify it. If there is no such file you can download it to current directory with this command:
$ sudo apt-get -d install sun-java6-bin && find /var/cache/apt/archives/ -iname sun-java6-bin* -exec ar -p '{}' data.tar.gz \; | tar -zxO ./usr/lib/jvm/.java-6-sun.jinfo | sudo tee .java-6-sun.jinfo
You can delete it afterwards. The reason I am not using .java-6-openjdk.jinfofile that probably is present in your Ubuntu installation is that it is slightly different that Sun’s one (some browser plugin entries are missing).
Copy file and replace path entries that they point to created link in /usr/lib/jvm/
$ sudo sed s/java-6-sun/sun-java6-manual/ .java-6-sun.jinfo | sudo tee .sun-java6-manual.jinfo - Now edit the beginning of file so it looks like below:
$ sudo vim .sun-java6-manual.jinfo
name=sun-java6-manual
alias=sun-java6-manual
priority=30
Choose whatever priority you like. - Now we have to register new alternatives in update-alternatives mechanism.
$ cat .sun-java6-manual.jinfo | grep -E '^(jre|jdk)' | awk '{print "/usr/bin/" $2 " " $2 " " $3 " 30 \n"}' | xargs -t -n4 sudo update-alternatives --verbose --install - Do the same with plugins
$ sudo update-alternatives --verbose --install /usr/lib/mozilla/plugins/libjavaplugin.so mozilla-javaplugin.so /usr/lib/jvm/sun-java6-manual/jre/lib/amd64/libnpjp2.so 30
$ sudo update-alternatives --verbose --install /usr/lib/xulrunner-addons/plugins/libjavaplugin.so xulrunner-1.9-javaplugin.so /usr/lib/jvm/sun-java6-manual/jre/lib/amd64/libnpjp2.so 30 - Now we are ready to switch default Java to the new one.
$ update-java-alternatives -l
It should list available java alternatives. It may look like:
java-6-openjdk 1061 /usr/lib/jvm/java-6-openjdk
java-6-sun 63 /usr/lib/jvm/java-6-sun
sun-java6-manual 1500 /usr/lib/jvm/sun-java6-manual - Set chosen option with:
$ sudo update-java-alternatives -s sun-java6-manual - Now confirm that java command is the new installed one
$ java -version
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)
Comments
Post a Comment