Thursday, December 3, 2009

Ubuntu 9.10, Java 5 and the Android Open Source Project

Currently there is an issue with building the Android Open Source project on Ubuntu 9.10 Karmic Koala, or more specific with the Java 5 support. Java 5 was obsoleted by Sun on October 30 2009 and is not part of the Ubuntu 9.10 distribution. However there is still a need to use Java 5 for building Android since Java6 is not yet supported. There are two methods to get Java5 working on Ubuntu 9.10.

Method 1 - download and install from Sun
This method will let you install the Java5 JDK in a separate directory and add it to the path when

Download the Java5 JDK for Linux from http://java.sun.com/javase/downloads/5u21/jdk
This is a binary file that you should save to a suitable location like ~/tools
In order to make i executable chmod the file as
$ chmod 777 jdk-1_5_0_21-linux-i586.bin
and run it
$ ./jdk-1_5_0_21-linux-i586.bin
This will install the jdk to the current directory.
To use the JDK5 tools you need to add it first in the path before building the Android Open Source Project
$ export PATH=~/tools/jdk1.5.0_21/bin:$PATH
This allows you to remove the JDK5 from the path when not building Android and use the standard Java settings instead.

Method 2 - use the Ubuntu 9.04 repositories to get Java5
This method adds the Jaunty repositories and installs Java5 as the default java setting in the system. Open the sources file (/etc/apt/sources.list) for editing, as root
$ sudo gedit /etc/apt/sources.list
and add:
deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse

save the file and close gedit. Next sync your sources by running
$ sudo apt-get update
and install
$ sudo apt-get install sun-java5-jdk
To set the system to use Java 5 you need to update your java alternatives by running
$ sudo update-alternatives --config java
Choose java-1.5.0-sun and you should be done.

Hopefully the Android Open Source Project will build with Java 6 shortly but the above solutions should get you going with platform work on Ubuntu 9.10.

4 comments:

  1. In addition I had to configure javac:

    $ sudo update-alternatives --config javac

    ReplyDelete
  2. I don't believe Java 5 is required anymore. I remember seeing an issue on one of the mailing lists where someone actually had problems compiling with Java 5. Someone from the Android team stated that they should now use Java 6 and that they just haven't updated the website yet.

    ReplyDelete
  3. I really like android I think its a great idea, but my biggest problem with when you said, " we just want Android to get all over the place"... My understanding is, if i were a developer. It would be very costly to create a nice UI that is catchy. So I would choose Android because its free and i would be able to save on costs... But the long-run problem I see with this is your phone just becomes a "conformist" and you loose the "unique-ness" of your phone. so when buyers decide on buying android

    Thanks
    Faris
    Android Blog

    ReplyDelete