Let the mobile games begin, Part 2

J2ME and .Net Compact Framework in action

1 2 3 Page 3
Page 3 of 3
  • For J2ME applications, we must extend the HttpURLConnection class in Personal Profile and HttpConnection class in MIDP to add cookie support. Interested readers can refer to one of my earlier articles (see Resources) for more details. Then we need to hack the HttpTransport class to replace all connection classes with the cookie-aware ones.
  • Since .Net Compact Framework does not support the cookie classes in the System.net package, we cannot simply plug in cookie-based HTTP session support in generated SOAP stubs. We would have to extend the basic transport classes to add cookie support. That would render the auto stub generator in VS.Net IDE much less useful.

On-device cache

A much-touted benefit of smart mobile clients is their ability to support offline mode through local data caching. Both J2ME and .Net Compact Framework provide excellent support for on-device data stores. My next column will discuss several leading relational databases on the J2ME platform. On the .Net Compact Framework platform, the flagship relational database is Microsoft's SQL Server CE. It is accessible through the common ADO.Net (Active Data Objects) API. The .Net Compact Framework also supports part of ADO.Net, which allows us to persist data to XML files easily.

Location APIs

The driving-directions application I demonstrated above is not particularly easy to use. For example, if we are lost driving, we need to find the route from the current location to the destiny. Finding the current street address and manually entering it into the device could prove a major nuisance. A driving-directions application that is aware of the current location context and automatically fills out the From field can be much more valuable to users. In fact, most LBS business models require access to the mobile client's current location.

As I have discussed, access to device extensions is one of the major benefits for both the J2ME and .Net Compact Framework platforms. Real-time location information can either come from on-device GPS devices or from network operators via network triangling techniques. The list below describes location determination technologies and APIs available on the two platforms:

  • Current GPS-enabled Java phones have proprietary APIs for on-device J2ME applications to access real-time location information. In the future, the Location API for J2ME (JSR 179, currently under public review) will provide a uniform interface to access location information from either GPS devices or network operators.
  • GPS device vendors also develop .Net custom controls for their devices. Those controls are reusable visual components that can plug into Visual Studio .Net. The new Microsoft location server will expose a new set of Web services APIs to integrate with network operator location servers. .Net Compact Framework devices can query the location server to find out real-time locations.

Put .Net Compact Framework and J2ME in action

In this article, I explored how to build GIS mobile clients using a mix of .Net Web services, J2EE, J2ME, and .Net Compact Framework technologies. XML Web services is the key technology that enables this heterogeneous design.

Both J2ME and .Net Compact Framework support similar sets of features and development tools. .Net Compact Framework better supports the Windows UI and is easier to start. On the other hand, J2ME has a rich set of third-party tools that conform to standard specifications. J2ME's abstract design also makes it easier to use advanced design patterns in sophisticated applications.

Due to the two platforms' technical similarities, business requirements, not technical merits, often determine a developer's choice. If the mobile application must work on a variety of devices from low-end cell phones to high-end PDAs, J2ME is the only choice. If you only deploy to Pocket PC devices and your developers already have .Net and VS.Net skills, .Net Compact Framework makes sense.

It has become increasing clear that Java and .Net technologies will in fact coexist for a long time to come. As Java developers, we should not only compete with .Net, but also learn how to interoperate with it. When we make a business case for J2ME, we must keep in mind the other options our clients (or bosses) might consider. That requires us to understand exactly how .Net works and what value it adds. As recently reported by vnunet.com, Microsoft is offering Java training to 140 of its consultants to better compete with Java. Microsoft surely knows the competition. We should too.

Michael Yuan is a PhD candidate at the University of Texas, where he is a research associate at the Center for Research in Electronic Commerce and an open source Java developer. He is the author of the upcoming book Enterprise J2ME: Developing Mobile Java Applications from Prentice Hall, to be released fall 2003.

Learn more about this topic

  • "Let the Mobile Games Begin," Michael Juntao Yuan (JavaWorld)

This story, "Let the mobile games begin, Part 2" was originally published by JavaWorld.

Copyright © 2003 IDG Communications, Inc.

1 2 3 Page 3
Page 3 of 3