Java and the Nokia N810 Internet Tablet

The Nokia N810 isn't really a phone. It's a Linux-based Internet tablet with wireless connection options—and you can write and run Java applications with it.


July 01, 2008
URL:http://www.drdobbs.com/open-source/java-and-the-nokia-n810-internet-tablet/jvm/java-and-the-nokia-n810-internet-tablet/208801979

Eric is a Dr. Dobb's contributing editor and software consultant. He can be contacted at [email protected].


If you follow my Dr. Dobb's Java blog (www.ddj.com/java), you know that I'm both a fan of Apple products and disappointed with Apple, mainly because Apple doesn't support Java on the iPhone. This led me on a search for a device that could run Java, connect wirelessly to the Internet from anywhere, and let me make voice-over-IP (VoIP) phone calls without a cell phone carrier. I haven't exactly found this device yet, but I've come close—real close—with the Nokia N810 Internet Tablet.

While Nokia considers the N810 as a phone, it really isn't a phone. It's a Linux-based Internet tablet device with wireless connection options, including 802.11b/g, Bluetooth, and WiMax. And with the help of some readily available software, you can run Java applications and make VoIP-based calls on the device, among many other things.

The Coolest Linux Device

With its 800×480 display and Mozilla-based Ajax-capable browser, the N810 delivers full desktop-quality web browsing (Figure 1) similar to the iPhone, but not a scaled down mobile version like with other cell phones.

The N810 comes with software to record/playback video streams, play music and movies with stereo output, and do everything you can do from a desktop Linux system in terms of multimedia. It also comes with map software and data, integrated with the device's GPS receiver, to show your location in real-time with directions to where you want to go. With an available software upgrade, it becomes a complete turn-by-turn navigation system.

In terms of communication, you can install Gizmo, GoogleTalk, and Skype. There's also IMAP4/SMTP/POP3 support for web-based e-mail systems such as GoogleMail and Yahoo!, with software that provides alerts as new messages arrive. Of course, being Linux-based, there are all kinds of software add-ons available (free and for fee) to add more media, entertainment, and productivity features to the N810.

[Click image to view at full size]

Figure 1: Websites are displayed in full desktop mode, not as scaled down mobile pages.

Adding Phone Support

Skype is a service that lets you make voice-over IP (VoIP) phone calls via the Internet from a computer with Skype software installed. It also comes with an instant messenger interface, letting you text or call the people on your contact list. Skype offers client software for Windows, Linux, Mac OS X, and mobile devices such as cell phones and the Nokia N810 (see skype.com/download/skype/nokia).

Skype calls are routed to whichever computer you're currently running the Skype client on. This can be a desktop, a laptop when traveling, or a mobile device like the N810. All that's required is an Internet connection, and people can use your Skype name or phone number to reach you, no matter where you are.

This leads to an interesting phone solution for the N810. For instance, while I'm home or in the office, I run Skype on the N810, which is connected to the Internet via 802.11b/g support. This is straightforward. However, when I'm on the road or away from a free or trusted wireless access point, I have the N810 connect to the Internet through my real cell phone via Bluetooth. I just leave my cell phone in my pocket and use the N810 for phone calls (with Skype). This also lets me maintain two individual phone numbers—one for my real cell phone, the other for my Skype N810 phone—with only one cell-phone bill. (You may need to pay for a data plan and possibly a wireless-tethering fee, depending on your cell carrier.)

Java and the Nokia N810: A Rich Mobile Platform

Although Nokia doesn't officially support Java development on the N810, it can easily be done. With help from the Jalimo project (jalimo.org), which offers a free Java stack specifically for mobile Linux devices, you can run just about any Java SE 5 application available on this device so long as it fits into its memory and storage profile. It also supports Eclipse SWT to help you build rich GUI applications.

To install Java (technically, the Cacao VM with GNU Classpath), you can use the N810's built-in Application Manager tool. This makes it easy to install, update, or uninstall any Debian-packaged Linux application that is compatible with the N810. To manually configure Application Manager for Jalimo, choose the Application Catalog under the Tools menu and add or create a new catalog with these parameters:

You can install packages that it suggests at that point; remember to include both "jalimo-console-example" and "jalimo-swt-example," because these pull in the needed files to run both command-line and GUI applications, along with the libswt-gtk-3.4-java graphics toolkit. The Cacao VM gets installed in /etc/alternatives, with a link created in /usr/bin so that it's in the path. By default, libraries get installed in /usr/share/java, with configuration files in /usr/share/java-config.

To do real Java development for your N810, connect it to a host computer running Windows, Linux, Solaris, or Mac OS X, and develop with an IDE such as Eclipse or NetBeans. Here, I focus on Eclipse because the Jalimo VM comes with Eclipse SWT support. You can connect the N810 to the host with USB cable. Once connected, the device's internal storage is displayed as an external disk that can be used to transfer files.

However, I found this to be a little constraining. Instead, I prefer to open a terminal session to the device from my host computer. To do this, install the available Maemo OpenSSH package, along with the Maemo PC Connectivity and Development package (maemo.org/downloads/product/OS2008/openssh and http://maemo.org/downloads/product/OS2008/maemo-pc-connectivity, respectively).

Once installed, your device has both a secure shell (SSH) client and server installed, as well as a package that creates a network connection over the USB cable. This is useful when you're out of range from a wireless network, or you want more security. I usually create SSH sessions from my Mac, and perform secure copies (SCP) over my wireless network. With this, I can develop an application on my Mac, SCP the files to the right place on the N810, and then start the application from my Mac's SSH session. Of course, if it's a GUI application, I need to interact with the device once it executes. However, this setup lets me do most of the typing on a full-sized keyboard (see Figure 2).

[Click image to view at full size]

Figure 2: The N810 has a backlit, full QUERTY keyboard that slides out from underneath.

Keep in mind that Nokia does not recommend installing the packages to gain root access because this can "brick the device," as they say, if you change or overwrite something critical on accident. So be careful! Also, be sure to change the root password to something secure, as it now will be open to attack when on public wireless networks. You can do this with the passwd command.

A Command-Line Java Application

Let's get started with a "Hello World!" command-line Java application:


public class Test {
  public static void main(String[] args) {
    System.out.println("Hello DDJ!");
  }
}


Once compiled on the host computer, copy the .class file to the device with this command (executed from the host):


> scp Test.class root@<IP ADDRESS>:/opt/hello


Next, in the SSH session on the device, execute the application with this command (from the /opt/hello directory):


> java Test


The result is "Hello DDJ!" displayed in the terminal window. Although a simple example, this shows that you can work with the N810 as with just about any other Linux-based computer.

Eclipse SWT GUI Java Applications

Again, because the Jalimo Java installation comes with both a GTK graphics toolkit and a port of the Eclipse SWT libraries, you can easily develop and run GUI-based Java applications for the N810. To get started, download the latest SWT for Eclipse for your host development computer; you can find it at eclipse.org/swt. In my case, I downloaded the Mac OS X version so that I can debug and test my applications locally before deploying to the device.

Next, create a Java project; I called mine SWTTest. With your project selected, click on the Eclipse File menu, choose Import, and then choose Existing Projects into Workspace from within the Import wizard window. Next, browse to the path where the SWT .zip file resides (from the download of SWT), and click the Finish button (see eclipse.org/swt/eclipse.php). In the end, you have access to SWT to develop and run with.

import org.eclipse.swt.widgets.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;

public class SWTTest {
  public static void main(String[] args) {
    Display display = Display.getDefault();
    final Shell shell = new Shell(display);
    shell.setLayout(new RowLayout(SWT.VERTICAL));
    
    Label label = new Label(shell, SWT.CENTER);
    label.setText("Hello DDJ!");
        
    Button button = new Button(shell, SWT.NONE);
    button.setText("close");
    button.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event arg0) {
        shell.dispose();
      }
    });
    shell.open();
    while (!shell.isDisposed())
      display.readAndDispatch();
  }
}
Listing One

To illustrate, I use Listing One, which opens a window that contains the text, "Hello DDJ!," along with a Close button to terminate the application. It's basically a GUI version of the "Hello DDJ!" application we ran previously. Once the .class files are copied to the device, you can execute the application:


> java -cp /usr/share/java/swt-gtk.jar:/usr/share/java/     swt-gtk-3.4.M3.jar:. SWTTest


Eclipse SWT comes with many sample SWT applications, one of which is the File Viewer application that lets you browse folders and files on any computer that can run Java. This application comes in handy on the N810, since it doesn't have a full-featured graphical file browser.

Other Development On the Nokia N810

The Maemo-provided N810 Scratchbox development platform and toolset is based on many commonly available open-source Linux development tools, such as Gnome. The platform includes support for glibc-2.5, GTK+ 2.10, and Qt graphics library and makes cross compilation and application development straightforward. It comes with a GNU cross-compilation tool chain and emulator based on QEMU

Although the official Nokia/Maemo development language for the N810 is C, ScratchBox lets you code in C++, Python, Ruby, C# with Mono, and Java. Applications can be packaged as Debian (.deb) archives, and made available for installation through the Maemo Application Manager tool. Nokia is also working to port Ubuntu Linux to the device, and one community member has ported the KDE desktop to the N810.

Conclusion

Recall I began with a search for an iPhone-like device with a rich UI, multimedia capabilities, and the ability to run Java applications and connect wirelessly to make mobile calls without a carrier. With its wealth of connectivity options, the Linux-based Nokia N810 certainly comes close—and with the recent addition of WiMAX support, it comes even closer. On the other hand, since WiMAX N810 currently only works with Sprint's Xohm network and the nonWiMAX N810 still requires a Bluetooth-enabled cell phone for mobile connectivity when away from a wireless LAN, it's not quite there yet.

But if you're looking for a more open device that runs open-source software and gives you choices in terms of application development and communication options, the Nokia N810 is a perfect choice. As WiMAX gains in adoption, and as the number of free WiFi hotspots grows, Nokia ITOS-based tablets currently offer a reasonable alternative to smart phones with expensive mobile calling plans.

Inside the N810 OS

Sometimes referred to as "ITOS," this Linux-based OS is a Nokia-sponsored community project called "Maemo" that is based on Debian GNU/Linux. ITOS tries to act like a desktop in your pocket. Most of its GUI and development platform comes from the GNOME project, and it uses Matchbox (window manager) and Hildon (GTK+ application framework) for the heavy lifting.

ITOS supports preemptive multitasking, but limits the display to one application at a time, although you can switch between them. It also includes BusyBox (busybox.net) as a lightweight form of the common UNIX tools found on the desktop. Other applications available include Skype, Gizmo, and Google Talk for VoIP; Canola and MPlayer for multimedia; MNotify, Claws Mail, and Modest for e-mail; the Gnumeric spreadsheet application; Pidgin, Jabber, and GoogleTalk IM clients; Rhapsody music service; and a host of other applications for remote connectivity, personal information management, GPS navigation, and so on.

The OS can be updated by re-flashing the device from a host computer via a USB connection. Future releases of the OS will support more IM clients, additional web browser choices, and an incremental OS update tool that will eliminate the need to re-flash the device. Other changes may include a new interface, given the community's success in making KDE 3, Openbox, and XFCE run on the OS, and Nokia's recent port of Qt.

—E.J.B.

Terms of Service | Privacy Statement | Copyright © 2024 UBM Tech, All rights reserved.