Channels ▼
RSS

Open Source

Java and the Nokia N810 Internet Tablet

Source Code Accompanies This Article. Download It Now.


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.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 

Video