Sunday, November 18, 2012

Install Java SDK in Nokia N900

Nokia N900 with Maemo Operating System is one true computer rather than a smartphone or an internet tablet. One of the judging criteria is whether we can develop applications right on the phone. With Nokia N900, we surely can.

Java platform is an amazing environment. We have the JRE with the JVM and the libraries, and of course with Java and a whole bunch of JVM languages like Clojure, Groovy, Scala etc. To develop applications in Java we need the Java Standard Development Kit (JDK) which contains the compiler and the supporting files. The cool thing about Maemo is that we can install JDK compiled for the ARM architecture.

The easiest way is to install the IceTea6 version of the OpenJDK preset at the maemo repository.

To manually install, follow the steps below.
1. Get OpenJDK for ARM. Cambridge Software Labs (link down) provides optimized version of OpenJDK for ARM. Download OpenJDK v1.6.0_0. (Mirror).
2. Copy the archive to /opt directory of the phone. Say you have downloaded or copied the file to MyDocs/tmp, then run the below command to copy it to /opt. We need to be root to preform the following operations. Install rootsh from the maemo-extras repository to get root privilege, if not done already.
cd  #home dir
sudo cp MyDocs/tmp/OpenJDK-camswl.tar.gz /opt #copy file
3. Extract the archive.
cd /opt
sudo tar zxvf OpenJDK-camswl.tar.gz #extract the archive
sudo rm OpenJDK-camswl.tar.gz #delete the archive
4. Add /opt/OpenJDK-camswl/bin to PATH.
cd /etc
sudo vim profile #open the file
Add the line to the file after the already present export path statement, save and exit vim (:wq). The file will look like:
# ...
export PATH="/usr/bin:/bin"
export PATH=$PATH:/opt/OpenJDK-camswl/bin
# ...
5. Exit and relaunch the terminal.
6. Test the installation by typing in the following commands.
java -version  #prints java version "1.6.0_0"
javac -version #prints javac 1.6.0_0
javap java.util.Date #lists all methods in Date class
Happy hacking !