You can follow android guide, and need other work also.
https://source.android.com/source/initializing.html
1. Install java6
Please dont use openjdk, please remove openjdk at first
$ sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
2. add source list for apt
sudo add-apt-repository "deb http://ppa.launchpad.net/ferramroberto/java/ubuntu natty main" & sudo apt-get update3. add source list partner
sudo add-apt-repository "deb http://archive.canonical.com/ubuntu maverick partner" & sudo apt-get update
4. install java6-jre
$ sudo apt-get install sun-java6-jre sun-java6-plugin5. Install java6-jdk
$ sudo apt-get install sun-java6-jdk sun-java6-plugin
6. Check the java version
$ java -versionjava version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
7. Optionally, update the default Java version by running:
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac
If you encounter version errors for Java, set itspath as described in the WrongJava Version section.
To develop older versions of Android, download and install the corresponding version of the Java JDK:
Java 6: for Gingerbread through KitKat
Java 5: for Cupcake through Froyo