Thursday, June 17, 2010

Linux for Java Programmer - setup Java environment

It is said that Ubuntu 10.04 removed sun-java package and replaced it with openjdk. So we need to add another souce manually.

1. Add jdk6 source

edit sources.list file
sudo vim /etc/apt/sources.list
The sources.list file is a key factor in adding or upgrading applications to your Ubuntu installation. This is also used by your system for system updates. The file is basically the roadmap for your system to know where it may download programs for installation or upgrade.
Append this line at the end:
#for ubuntu 9
deb http://archive.canonical.com/ lucid partner
#for ubuntu 10
deb http://archive.canonical.com/ubuntu maverick partner

#update source
sudo apt-get update

2. install jdk6



sudo apt-get install sun-java6-jdk
The jdk will be installed in this directory:
/usr/lib/jvm/java-6-sun

3. Check your jdk version


java -version
This is my jdk information
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)

4. Set JAVA_HOME variable


vi ~/.bashrc
append the following line at the end:
export JAVA_HOME=/usr/lib/jvm/java-6-sun

0 comments: