Install java using deb package in Ubuntu

Nowadays Java seems to be the most popular application development platform because of its portability and availability of APIs. Anyway, standard Java by Sun only provides pre-package version in RPM format and tar format. In order to install this package on other Linux distros like Ubuntu, deb package should be constructed for easily managing the package later. Fortunately, Ubuntu offers lots of tools to automate these tasks. For a fresh Ubuntu, you can follow below instruction to install Java properly.

  1. Edit /etc/apt/sources.list to include multiverse by adding below lines
    deb http://archive.ubuntu.com/ubuntu breezy universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu breezy universe multiverse
  2. Update repository
    apt-get update
  3. Install necessary packages
    apt-get install fakeroot java-common java-package build-essential
  4. Download Java 2 Platform, Standard Edition, v1.5.0 (J2SE) SDK from http://java.sun.com/j2se/1.5.0/download.html
  5. Move the downloaded file, jdk-1_5_0_06-linux-i586.bin to temporary directory
  6. Run java-package as follow (you must not be root)
    fakeroot make-jpkg jdk-1_5_0_06-linux-i586.bin
  7. Install the result the deb package, sun-j2sdk1.5_1.5.0+update06_i386.deb
    dpkg -i sun-j2sdk1.5_1.5.0+update06_i386.deb
  8. Choose java if you have more than one alternative
    update-alternatives --config java
  9. set JAVA_HOME environment to /usr
    export JAVA_HOME=/usr
  10. Verify installation as follow
    java -version

That’s all! You can manage this java package like other packages in Ubuntu and Debian.

Technorati Tags: , , , , , , ,

Post new comment