Skip navigation.

Sign up | Lost password? | Help

Welcome to My Technical Blog

Install Java JRE 1.6.0 (Update x) on Hardy as the Default Java Runtime

,

I wanted the latest version of Sun’s JRE installed on my system, and to have it set up as the default Java Runtime Environment whenever I ran a Java executable, or Jar file. It’s actually a pretty easy process, so this is a relatively short tutorial, but I’ll cover both the 32 bit and 64 bit installations, since aside from differences in file names, the set up is identical.

FROM: http://www.64bitjungle.com/ubuntu/install-java-jre-160-update-x-on-hardy-as-the-default-java-runtime/

Installing JRE

First, decide on which architecture will be installed, and download the relevant file from the main Java website. At the time of writing, 1.6.0 u11 can be downloaded from the following: 32 bit JRE, and 64 bit JRE. I wanted to install the x64 version, and so downloaded jre-6u11-linux-x64.bin to my Desktop. I also wanted to install it in its own directory in /opt, and so created a directory for it to sit in:

cd /opt
sudo mkdir java

I was also experimenting with the 32 and 64 bit versions, so made two extra directories within java:

cd java
sudo mkdir 32 64

I then copied the relevant file(s) to the respective directories, and made them executable:

32 bit:

sudo cp ~/Desktop/jre-6u11-linux-i586.bin /opt/java/32
sudo chmod 755 /opt/java/32/jre-6u11-linux-i586.bin

64 bit:

sudo cp ~/Desktop/jre-6u11-linux-x64.bin /opt/java/64
sudo chmod 755 /opt/java/64/jre-6u11-linux-x64.bin

The final part of the installation simply involves executing the binary file:

32 bit:

cd /opt/java/32
sudo ./jre-6u11-linux-i586.bin

64 bit:

cd /opt/java/64
sudo ./jre-6u11-linux-x64.bin

Regardless of architecture, this should create a sub directory called jre1.6.0_11.

Setting JRE 1.6.0 u11 as Default

The process simply involves telling the system that there is an alternative Java binary available, and to use this binary to execute an “java” commands:

32 bit:

sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/32/jre1.6.0_11/bin/java" 1
sudo update-alternatives --set java /opt/java/32/jre1.6.0_11/bin/java

64 bit:

sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/64/jre1.6.0_11/bin/java" 1
sudo update-alternatives --set java /opt/java/64/jre1.6.0_11/bin/java

Follwing the second command, there should be output to the terminal something along the lines of:

Using '/opt/java/32/jre1.6.0_11/bin/java' to provide 'java'.

or,

Using '/opt/java/64/jre1.6.0_11/bin/java' to provide 'java'.

depending on the architecture installed. That’s it. Now every time “java” is run, either explicitly from the Terminal, or via a Java executable (such as the Eclipse IDE), Ubuntu will use the newly installed /opt/java/64/jre1.6.0_11/bin/java binary as opposed to the binary installed by default. Simple, eh?

FROM: http://www.64bitjungle.com/ubuntu/install-java-jre-160-update-x-on-hardy-as-the-default-java-runtime/

Một ví dụ về đa hình trog Java ( còn cập nhật )JDK/Netbeans on Ubuntu

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies

November 2009
M T W T F S S
October 2009December 2009
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30