- MemMaker for the .NET Compact Framework
-
Does everyone remember the good old days of DOS when we used to spend our time making more of the 640 KB memory space available for our drivers, programs, TSRs and even Windows? Things like QEMM, HIMEM.SYS and EMM386.EXE bring back fond memories for me. We had this one slot and Billg said we’d never need more than 640 KB.

Some of us even switched to OS/2 which could give us 740 KB to our DOS sessions while providing them with preemptive multitasking. Yes, I could run multiple DOS games in multiple windows simultaneously with no degradation. Wow, now I had a bunch of crash-protected slots each with 740 KB of memory.
If you fast forward to today, you’ll see that Windows CE 5.0 and Windows Mobile 6.x shares some commonalities with their forefathers from the 80’s and 90’s. The 32-bit embedded operating system that we rely on to power our Windows phones is made up of a bunch of slots. The mobile applications that you build run inside one of these slots and unlike DOS with its 640 KB memory space, your app gets 32 MB of virtual memory space. But just like with DOS, you don’t get access to the whole space because other things like system DLLs are already eating into your free virtual memory.
Many of you might not care because you build simple apps that use very little memory. On the other hand, most of the people and organizations I work with build the largest, most memory-intensive applications ever seen on the mobile device. Needless to say, these folks aren’t too pleased that they don’t get the whole 32 MB of virtual memory that’s coming to them. They probably wish they a utility like QEMM or MemMaker to put things in high memory.
I recently met with a good friend of mine, Glen Jones, who wanted to share some interesting findings with me. Keep in mind, not only do I consider Glen and his colleagues to be some of the top Compact Framework developers in the world, his team members designed and developed of one of the world’s largest, most complex managed apps running on a Windows Mobile device. Like many organizations that have built very large Windows Mobile applications, free virtual memory issues and the "DLL Crunch" have deprived this app from of all the memory it would like to have. Brian Pike, one of the architects on this "Dream Team" recently discovered that by keeping their application’s EXE empty and putting all the forms, code, resources, and data in managed DLLs, he reduced the amount of virtual memory his app uses inside its slot while at the same time taking advantage of memory outside the slot in the 1 GB shared memory area.
To help you visualize this incredible finding, I’m going to show you 2 pictures of the Windows Mobile process slots running a Compact Framework application two different ways. The virtual memory viewer you see running in the emulators below shows the 32 slots in the User space of the OS. Everything in Red is free virtual memory, Blue is committed memory and Green is reserved. Slot 1 is crammed full of ROM DLLs and you can’t help but notice the area of Blue at the top of every other slot. That’s space out of everyone’s slot being used by system and other native DLLs which means nobody’s going to get their fair share of their 32 MB slot space.
On the left you’ll see a NETCF app called StandardExe.exe running in slot 14 of the operating system. This simple managed EXE has a 2.25 MB bitmap bound to it as a resource and a single form that compiles to the same size as the bitmap inside it. If you look at the picture on the left, you’ll see a 2.25 MB Blue area coming up from the bottom of slot 14. This represents the space being taken up by the EXE.
On the right a NETCF app called OptimizedExe.exe running in slot 11 of the operating system. This managed EXE is completely empty. The Main function calls into a static class of a managed DLL and that’s it. No mas. This results in an EXE with a file size of 5 KB. In the managed DLL we have the same 2.25 MB bitmap bound to it as well as a simple form. This compiles into a 2.25 MB DLL called OptimizedDLL.dll. When you look at the picture on the right, you’ll be hard-pressed to see any Blue area coming up from the bottom of slot 11. A closer look reveals the 2.25 MB DLL is nowhere to be found either.
This is pretty cool and has the potential to unleash the largest, most powerful games and applications Windows phones have ever seen. So the big question is, how is this happening? Is it magic?
Those of you who have read Steven Pratschner’s blog know that the Compact Framework memory maps your managed EXE and DLLs into the 1 GB shared memory area outside the slot your app is running which is cool. What you may not know is that the OS automatically blocks out virtual memory at the bottom of your slot that’s the same size as your EXE. So even though the CLR is in control of app execution and is giving you lots of love by putting your managed EXE up in the shared memory area, Windows CE takes away a valuable chunk of memory because it thinks that’s where your EXE is running. Guess what, your app isn’t running there and it’s not native. For those of you with giant managed EXEs, you’re losing out on a lot of virtual memory in your slot that could be put to good use. So the first lesson here is to do what Brian did and make your EXE nothing but an empty stub used to launch your app which really lives inside managed DLLs.
Your empty EXE code should look like the following:
using System;
namespace OptimizedExe
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[MTAThread]
static void Main()
{
OptimizedDLL.StartUp.Main();
}
}
}
Your DLL code should look like the following:
using System;
using System.Windows.Forms;
namespace OptimizedDLL
{
public class StartUp
{
public static void Main()
{
Application.Run(new Main());
}
}
}
So now that you’ve learned how to instantly give your managed apps more memory by beating Windows CE at its own game, let’s talk about the curious case of your managed DLL. If you’ve read Reed Robison’s blog discussion about Slaying the Virtual Memory Monster, you know that DLLs seem to take up everyone’s virtual memory from the top of the slot down which doesn’t sound too fair. DLLs keep pushing their way down everyone’s slot causing something we call the “DLL Crunch” as free virtual memory get’s squeezed between the DLLs and EXEs. I’ve got some good news for you. Managed DLLs do not exhibit this same behavior. In fact, not only do they not use up memory in all the other slots of your Windows phone, they don’t even push downward on the memory of your own slot. How could this be?
Managed DLLs are not DLLs. The CLR just treats them as files that it memory maps into the 1 GB shared memory area. To the Compact Framework, managed EXE and DLL assemblies are just files full of IL that it maps outside your process slot. So now you know where the 2.25 MB bitmap that we bound to OptimizedDLL.dll is. It’s beyond the 32 MB barrier of your slot and therefore not using up your valuable memory.
So if I follow this new pattern for NETCF development, will my slot ever have virtual memory allocated or do I get a free lunch?
While there’s no free lunch, you did get a buy one get one free discount. The JIT compiler is running in your slot and it pulls in IL from the 1 GB space as needed to compile the current call stack. Resources that aren’t designed to be compiled or executed will never be pulled down here. The GC Heap is in your slot and that’s where your currently allocated Objects and instance variables are hanging out. Your slot maintains a 64 KB Stack for every Thread your app spawns and the AppDomain Heap maintains a representation of the data structures found in your assembly’s IL.
So what are the big takeaways here?
You can eliminate the erroneous and wasted allocation of EXE virtual memory in your slot by following the pattern of using an empty stub managed EXE to kick off your application. Windows CE will now only block out 5 KB of memory. Thanks Brian!
You can take better advantage of the 1 GB shared memory area by putting your entire application inside managed DLLs. This will make your app a good neighbor by not creating the dreaded “DLL Crunch” for all the other apps on your Windows phone. It also reduces the amount of memory that has to be allocated inside your slot.
This new pattern of managed development on the Windows Mobile platform is a true breakthrough in memory management. Come join me at Tech Ed 2009 this May in Los Angeles for a complete deep dive on this new way of building memory-intensive games and applications.
- Rob
- Windows Mobile 6.5 is getting Stylish
-
Check out one of the great new device themes from designer Isaac Mizrahi!

On the technical side of this, we’ve updated memory allocation so that switching Today screens and backgrounds repeatedly does not cause animations to become slower, the background image to become black, or the device to become unresponsive. This is all good!
-Rob
Technorati Tags:
Windows Mobile
- Microsoft Unveils Its Developer Strategy for the Next Generation of Windows® Phones
-
Familiar tools, a large worldwide customer base and transparent policies will allow mobile developers to innovate and generate new revenue opportunities with Windows Mobile 6.5 and Windows Marketplace for Mobile.
Today we’re announcing new details about how developers can build and sell applications for Windows® phones through Windows Marketplace for Mobile, the recently announced application marketplace available with the Windows Mobile 6.5 operating system.
Developers who sell applications through Windows Marketplace for Mobile will receive 70 percent of the revenue from the sales of each application. In addition, they will be able to set the price for their applications in each market, maximizing their revenues based on targeted pricing strategies. Developers can also choose to distribute their applications at no cost. Up to five application submissions to Windows Marketplace for Mobile is included in the introductory annual registration fee of $99 (U.S.). Each additional submission within the annual period will cost $99 (U.S.). The registration fee is waived for student developers who want to reach Windows® phones customers, through enrollment in the Microsoft DreamSpark program.
With Windows Marketplace for Mobile available in 29 countries, developers will be able to tap into a broad international customer base. At the same time, Microsoft will continue working with developers to ensure that their applications run optimally on Windows® phones by running a rigorous certification and testing process before applications go to market. Developers will be able to see detailed feedback during and after the certification process of their application on the Windows Marketplace for Mobile developer portal. Ultimately this enables developers to devote more time to writing innovative applications, and less time trying to navigate the approval process. Developers will have access to all details once the registration doors open in the spring, and will be able to start submitting their applications later this summer.
Developers can utilize familiar tools and technologies to build unique experiences for the Windows Mobile platform through Windows Marketplace for Mobile, including the Windows Mobile 6 SDK, .NET Compact Framework 3.5, and SQL Server Compact 3.5.
With more than 20,000 applications already in market, Windows Mobile is among the most popular platforms for developers. Windows Mobile 6.5, the next generation of the Windows Mobile operating system, will allow developers to build innovative mobile applications without having to learn new skills or programming languages, by leveraging familiar desktop and server development tools such as Win32, Active Template Library and Microsoft Foundation Classes (Visual C++), Visual C#, Visual Basic .NET, ASP.NET and asynchronous JavaScript and XML (AJAX).
Let’s get after it!
-Rob
- Windows Mobile 6.5 Announced at Mobile World Congress
-
Steve Ballmer and Andy Lees announced Windows Mobile 6.5, My Phone, and Marketplace in Barcelona this week.
Check out Engadget's video walkthrough of Windows Mobile 6.5 running on a Touch Diamond 2:
http://www.engadget.com/2009/02/16/windows-mobile-6-5-walkthrough-with-engadget/
-Rob
- Mobile Architecture Pocket Guide v1.1
-
Just wanted to let everyone know that version 1.1 of the is now available on CodePlex at http://www.codeplex.com/AppArch/Release/ProjectReleases.aspx?ReleaseId=19798. This is the first patterns & practices update to this guide since 2002 so it's a welcome sight to to have it out there for all our Windows Mobile developers.
I've spent the last couple of months working with J.D. Meier, Rabi Satter, Rob Boucher and the rest of the P&P team to tune, tweak and update the new Mobile Architecture Pocket Guide to ensure that it's as accurate and relevant to today's Windows Mobile platform and runtimes as possible. The guide's chapters include:
- Ch 01 > Mobile Application Architecture
- Ch 02 > Architecture and Design Guidelines
- Ch 03 > Presentation Layer Guidelines
- Ch 04 > Business Layer Guidelines
- Ch 05 > Data Access Layer Guidelines
- Ch 06 > Service Layer Guidelines
- Ch 07 > Communication Guidelines
- Ch 08 > Deployment Patterns
Our goal is to empower our Windows Mobile developer community as much as possible, and while this guide may seem like it's targeted exclusively to developers, I ensured that the IT Pro side of the house is accommodated as well. Mobile infrastructure elements of this guide include System Center Mobile Device Manager (Deployment), SQL Server (Sync Services + Merge), IIS (Web Services + Sync + WCF), Exchange (WCF Store and Forward) and Active Directory (Auth).
Download it, take if for a spin, and give us your feedback so we can keep improving it.
- Rob
- The Desktop Web Comes to Windows Mobile
-
Internet Explorer Mobile 6 transforms the web for devices based on Windows Mobile 6.1.4. A rich, desktop web with flicking, panning and zooming is coming to Windows Mobile. Fast, robust Javascript support is included ala the IE 8 Javascript engine. Plugin support includes Flash Lite 3.1, Silverlight, and the embeddable Media Player. Device developers don't have to wait for shipping devices in order to get started. The Windows Mobile 6.1.4 Emulator Images can be found at http://www.microsoft.com/downloads/details.aspx?FamilyID=1A7A6B52-F89E-4354-84CE-5D19C204498A&displaylang=en.
- New emulator image resolutions:
Windows Mobile 6.1.4 Standard
DPI: 131 - Resolution: 320 x 320 pixels
DPI: 131 - Resolution: 400 x 240 pixels
DPI: 131 - Resolution: 440 x 240 pixels
- Windows Mobile 6.1.4 Professional
DPI: 96 - Resolution: 240 x 400 pixels
DPI: 192 - Resolution 480 x 800 pixels
Take that Webkit!
-Rob
- See you in Barcelona for Tech Ed EMEA Dev
-

Looking forward to seeing lots of familiar faces and meeting new ones starting December 10th at Tech Ed EMEA! While I ran the Windows Mobile track for Tech Ed North America last June in Orlando, this time around I'll just be delivering a couple of presentations and spending most of my time helping empower delegates to create incredible mobile applications. I'll be delivering the following breakout sessions:
| |
|
MBL301 |
What's New in the Windows Mobile Line of Business Solution Accelerator 2008 |
November 10 16:00 - 17:15 |
Room 121 |
| This session walks through the new features that we have added to the Windows Mobile Line of Business Accelerator 2008; features such as adapting your application to any device or screen size with a single binary, sync services, store and forward, and advanced data access objects with Microsoft .NET CF 3.5. |
|
| |
|
MBL310 |
Mobilize your Enterprise and Achieve Global Scalability with Windows Mobile and SQL Server Compact |
November 11 15:15 - 16:30 |
Room 121 |
| With the world's largest organizations rolling out tens of thousands of Windows Mobile devices to empower their respective workforces, the ability to create mobile line-of-business solutions that can support large user populations is critical. Based on his third book on Windows Mobile development, Rob Tiffany shows you how to take the Microsoft SQL Server data you use to run your organization and make it available to all your mobile employees. Utilizing the performance, scale-out, and filtering capabilities of Merge Replication Republishing, Rob shows you how to build an n-tier mobile synchronization architecture designed to scale to hundreds of thousands of devices. Take the guesswork out of mobilizing your enterprise by tapping into the experience of one of the world's foremost authorities on Windows Mobile infrastructure and development. |
|
| |
See you there!
- Rob
- New Resco MobileForms Release for NETCF
-
Just in case all you mobile developers didn't hear, Resco has released Volume 3 of their MobileForms Toolkit 2008.
Resco MobileForms Toolkit contains:
- Resco CustomKeyboard for .NET – flexible control supporting custom keyboard layouts
- Resco SmartGrid for .NET - powerful grid control with built-in auto edit capabilities
- Resco AdvancedList for .NET - professional list control suitable for small displays of mobile devices
- Resco AdvancedTree for .NET - featured tree control excellent for displaying tree-organized data
- Resco DetailView for .NET - elegant and quick way of creating user input forms
- Resco CompactChart for .NET - charting control supporting 5 chart types
- Resco OutlookShortcutBar for .NET - popular shortcut control, common to all modern applications
- Resco OutlookWeekCalendar for .NET - day/Week appointment scheduling control
- Resco OutlookMonthCalendar for .NET - month/Year scheduling control
- Resco OutlookDateTimePicker for .NET - modern version of common control providing advanced styles
- Resco InkBox for .NET - ink control suitable for quick notes or signatures
- Resco ImageBox for .NET CF - versatile image control supporting various graphic formats
- Resco ImageButton for .NET CF - adjustable, modifiable and skinnable button
- Resco Audio for .NET CF - powerful library for playing and recording audio
- Resco Zip for .NET - industry standard compression library
For more information about Resco MobileForms Toolkit, visit http://www.resco.net/developer/mobileformstoolkit/default.aspx.
Additionally, they'll be at Tech Ed EMEA in Barcelona exhibiting at booth E12 so please check them out to see if their controls meet your mobile development needs.
-Rob
- Announcing Sync Framework v2 CTP1
-
I just wanted to give you a heads-up about the availability of Sync Framework v2 CTP1 . Sync Framework 2.0 expands on the capabilities offered by Sync Framework 1.0:
- Adds features that cater to new scenarios or scenarios that were difficult to support.
- Reduces the amount of work required to develop providers.
- Supports more data sources with new built-in providers.
The major new features included in this initial CTP are:
- Simple Providers
- Reduces the amount of work required to develop providers, especially when the data source has very few synchronization-related capabilities, such as change-tracking.
- The goal is to enable a developer to write a provider without having to become a synchronization expert. The majority of the code that is required for a simple provider is limited to that responsible for interacting with the data source.
- Change Unit Filtering
- Different data sources can have different representations of the same data types, with some data sources offering a richer and more complete representation than others. This is especially true when you compare data type representations on a PC and on a device; the device will often support only a subset of the data supported by the PC.
- Sync Framework caters to scenarios in which a mixture of data sources is being synchronized, each with a different representation of the data type. Filtering support has been added to enable a provider to specify that the replica it serves is only able to store a subset of the data. The synchronization metadata and synchronization process have both been enhanced to handle this filtering efficiently.
- Filter negotiation
- When a destination data source is only storing a subset of data, then it is more efficient if the source provider uses a filter to enumerate only the data that can be stored by the destination.
- Filter negotiation allows a destination provider to specify it would like one or more filters to be used by the source provider; the source provider can accept or reject a filter. If a source provider does not support the requested filters then the destination provider can choose to receive all the data and do the filtering itself.
- Sync Framework is responsible for calling the providers appropriately to negotiate filter usage.
For more details please visit the Microsoft download center at:
http://www.microsoft.com/downloads/details.aspx?FamilyId=109DB36E-CDD0-4514-9FB5-B77D9CEA37F6&displaylang=en
Happy Synching!
-Rob
- Chapter 1 of my new Book is Ready!
-
Mobile Data Synchronization with Microsoft SQL Server 2005 and SQL Server Compact > Second Edition
Achieving Global Scalability via Merge Replication Republishing
Download and review the PDF from my Windows Live SkyDrive @
http://cid-8b9c82da88af61fc.skydrive.live.com/self.aspx/Sync/Ch%201.pdf
The new book shows you how to scale out your Merge Replication Architecture with Republishing. It's chock full of new insight to show you how to get the most performance and scalability out of your system. It also shows you how to make replication Subscriptions available to the Internet via ISA Server 2006 or System Center Mobile Device Manager.
Check it out and let me know what you think.
Best Regards,
Rob
- Listen to Rob's Windows Mobile Interview on .NET Rocks!
-

I was recently interviewed by Carl Franklin and Richard Campbell who run one of the Internet's most popular developer sites, .NET Rocks! You can catch the interview at http://www.dotnetrocks.com/default.aspx?showNum=384 where you can either listen to it live via the website, or download it to your favorite device to listen later.
I cover the current state of Windows Mobile + the entire ecosystem including OEMs, Mobile Operators, developers and who does what within Microsoft's Mobile Commications Business in Redmond and the Mobile Development Center in Hyderabad. I take Carl and Richard on a deep dive of our latest mobile development technologies and techniques with the .NET Compact Framework, SQL Server Compact, and WCF Store and Forward just to name a few. I also cover all the features of System Center Mobile Device Manager including OTA software distribution, Group Policies, Mobile VPN security and Domain join.
Download it and give it a listen
- Rob
- Old School Windows Mobile :: Getting Started with Java on PDAs
-
Below is an article I wrote back in 2002 that described how to build Personal Java apps on the iPAQ during the age of Pocket PC 2000, Embedded VB and C++:
PDAs are becoming a permanent fixture in the everyday lives of consumers and business people. There's no question that we have Palm to thank for bringing us a small, pen-based, easy-to-use organizer to help keep our busy lives on track.
At the same time, Microsoft has been trying to hit one out of the park for years with its Windows CE operating system running on a variety of handheld devices. As with everything else at Microsoft, it usually takes them three times to get something right, and the Pocket PC is no exception.
Based on Windows CE 3.0, the Pocket PC looks and works much like its Palm rival. However, the Pocket PC is different due to its use of more powerful hardware, more memory, and a full-blown, multithreaded operating system - it's more like a small computer than an organizer.
The success of the Pocket PC in the marketplace is largely due to the unique styling and powerful processor found in the Compaq iPAQ. With all the other Pocket PC devices shaped like unimaginative rectangular boxes, the iPAQ has had an easy time gobbling up market share. That said, the Palm is still the market-share king and isn't sitting around on its laurels waiting to become another "Netscape-style" victim of Microsoft.
As evidenced by the dominance of Windows, having the most developers writing applications for a given platform does more for its success than superior technology. The existence of a variety of programming languages for a platform plays a large role when it comes to building the critical mass of applications needed to put that platform over the top. Development for the Palm is currently being done with languages such as C/C++, CASL, NS Basic, J2ME, and AppForge (Visual Basic). Until recently, the Pocket PC development languages included eMbedded Visual Basic, NS Basic, and eMbedded Visual C++.
The Palm has clearly had the upper hand in the language department, even though its operating system lags behind the Pocket PC in features. This is quite a paradox for the Pocket PC camp, which seems to have superior technology on its side. Even the two BASIC tools for the Pocket PC are actually based on VBScript, with its lack of true data types and horrible error handling. So, the only way to take advantage of everything Windows CE 3.0 has to offer is to use an eMbedded Visual C++ tool, which most developers find intimidating at best.
Last summer, the Pocket PC gained a powerful and easy-touse language that enabled developers take full advantage of the Windows CE operating system. Sure to make Microsoft executives cringe, Java has finally arrived for the iPAQ! Insignia Solutions (http://www.insignia.com/) released its Jeode Embedded Virtual Machine for the Intel StrongARM processor.
The Jeode EVM is a Sun Authorized Virtual Machine that is certified and fully compliant with Sun's PersonalJava 1.2 and Embedded Java 1.0.3 specifications. It can run Java applets and applications, use a dynamic compiler to run Java apps up to six times faster than a normal JVM interpreter, and provide a preemptible, concurrent garbage collector for superior memory management. Most developers don't know much about Sun's PersonalJava and usually think about MIDP when talk of Java development for a handheld device comes up.
PersonalJava, as opposed to MIDP, wouldn't fit very well on a Palm (for example), nor could all of its classes be utilized, since the Palm OS doesn't provide all the underlying services required.
Since the iPAQ doesn't skimp on memory - 32MB is now the minimum - you don't have to compromise on your Java. PersonalJava is roughly equivalent to JDK 1.1.8 with a dash of JDK 1.2 classes and APIs thrown in for good measure. The Jeode EVM requires only 3-4.5MBs of space, depending on your need for the internationalization classes. This means that the Java Native Interface plus all of the following classes are available to you:
- java.io: System input and output through data streams, serialization, and the file system
- java.util: Collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes
- java.util.jar: Classes for reading and writing the JAR (Java ARchive) file format
- java.util.zip: Classes for reading and writing the standard Zip and GZip file formats
- java.lang: Core Java API classes
Core Java API Classes
- java.lang.reflect: Classes and interfaces for obtaining reflective information about classes and objects
- java.net: Classes for implementing networking applications
- java.math: Classes for performing arbitrary-precision integer arithmetic (BigInteger) and arbitrary-precision decimal arithmetic (BigDecimal)
- java.text: Classes and interfaces for handling text, dates, numbers, and messages
- java.rmi: Classes that allow Java to make remote procedure calls
- java.rmi.dgc: Classes and interface for RMI distributed garbage collection
- java.rmi.registry: A class and two interfaces for the RMI registry
- java.rmi.server: Classes and interfaces for supporting the server side of RMI
- java.security: Classes and interfaces for the security framework
- java.security.acl: Interface to access control list data structures
- java.security.cert: Classes and interfaces for parsing and managing certificates
- java.security.interfaces: Interfaces for generating RSA and DSA keys
- java.security.spec: Classes and interfaces for key specifications and algorithm parameter specifications
- java.sql: An API for accessing and processing data found in databases
- java.beans: Classes that support the creation and usage of embeddable, reusable software components
- java.applet: Classes necessary to create an applet and the classes an applet uses to communicate with its applet context
- java.awt: Classes for creating user interfaces and for painting graphics and images
- java.awt.datatransfer: Interfaces and classes for transferring data between and within applications
- java.awt.event: Interfaces and classes for dealing with different types of events fired by AWT components
- java.awt.image: Classes for creating and modifying images
As you can see by all the packages, classes, and APIs supported in PersonalJava, you have a handheld programming language that’s more feature-rich than eMbedded Visual Basic, AppForge, NS Basic, or MIDP. Only eMbedded Visual C++ rivals PersonalJava in power, but it can’t compare when it comes to developer productivity. In addition, the Jeode EVM supports the creation of console applications, and a Timer class is provided for use in animations, scheduling jobs, or any situation in which you need to execute code at set intervals.
Let’s cover what PersonalJava can’t do. Generally, anything that’s dependent on Java 2 is off-limits, with the exception of the handful of JDK 1.2 classes found in PersonalJava. Alas, Swing is officially unsupported in this environment.
There is a workaround to make JFC 1.1.1 work with PersonalJava that requires you to change a line of code in one of the classes that make up swingall.jar. I’ve made this change myself and it’s a good news, bad news situation. On the one hand, you get to use great-looking, Swing user interface elements on your iPAQ. The downside is the deployment of a 2MB swingall.jar file, slow program loading times, and extremely poor performance.
In my opinion, you should stick with AWT and other GUI widgets that are based on JDK 1.1. You may have to do some digging to find things like AWT-based grids and tab controls, but they’re out there. My advice is to look in your old copies of “pre-Swing” JBuilder and VisualCafé to find lots of GUI JavaBeans based on AWT.
Building Applications
So what kind of cool applications can you build on your iPAQ with this technology?
- A single-tier application that uses JDBC to store and manipulate data on a local, pure-Java database such as Cloudscape or PointBase
- A wireless two-tier client that uses JDBC to communicate directly with enterprise databases such as Oracle and SQL Server
- A wireless n-tier client that uses RMI to make remote procedure calls to Java objects on a middle-tier server
- A mobile, wireless RMI server that allows other Java clients to invoke its objects
- A chat/instant messenger client or server using Socket and URL classes
- A wireless telemetry client that remotely monitors vital corporate assets from anywhere
- A remote data-entry application to be used by personnel who work in the field.
- Miniature, mobile versions of just about any desktop or server Java application you’ve ever built.
I think you get the gist of where I’m going here. The best recommendation I can make is to get your hands on a wireless Ethernet (802.11b) or a CDPD (mobile Internet) card so you can start building the kind of distributed wireless applications that will take you to the next level in your career as a developer (you probably never thought that going backwards to Java 1.1 would help advance your career).
For complete information and the APIs related to PersonalJava, go to the PersonalJava application environment Web site at http://java.sun.com/products/personaljava.
Getting Jeode
Now that you know what PersonalJava and the Jeode EVM are capable of, it's time to go get it. The Jeode EVM is available for purchase on the Handango Web site at http://www.handango.com/PlatformProductDetail.jsp?siteId=1&platformId=2&productType=2&catalog=0§ionId=0&productId=17215for $19.99. The software is downloadable from the Web site after you go through the shopping cart and checkout routine.
Once the software is downloaded, load it onto your Pocket PC. To begin the installation, be sure the iPAQ is in its cradle and connected to your PC via ActiveSync. Double-click on the "JeodeForArmPocketPC" executable to start the InstallShield Wizard. When asked to install Jeode in the default folder, click Yes. The installation shouldn't take more than a minute.
To verify the installation and to be sure the EVM is working properly, complete the following steps: from the Start menu on your iPAQ, navigate to Programs|Jeode|EVM to bring up the EVMConsole (see Figure 1).
Figure 1:
The EVMConsole is equivalent to the DOS/Command Prompt you have in Windows. From here you can launch both console and AWT Java applications. There are a number of command line options that you can pass to the EVM when using the EVMConsole:
- -?, -h, or -help: Displays Jeode EVM help.
- -cp <pathnames> or - classpath <pathnames>: Here you specify the path(s) used for loading classes. Semicolons separate multiple pathnames that point to JAR files. If you need to launch a Java application that resides in a JAR file called "ipaq" that sits in the "windows" directory with a main class called "frame1", you would type in "-cp \windows\ipaq.jar frame1". To take this a step further, if your application needs classes found in a third-party JAR file, you might type in "-cp \windows\lib\jcbwt363.jar;\windows\ipaq.jar frame1". If you put your application in a package, you would type in "-cp \windows\ipaq.jar mypackage.frame1". That said, application classes that don't reside in a JAR file can be executed directly without the use of "-cp".
- -D <propertyName> = <value>: This supplies the value for either a Jeode EVM or Java system property. To keep the console open after an application has been executed, use the command "-Djeode.evm.console.local.keep=TRUE". If you have a console application that sends more than one screen of data to the console, use the command "-Djeode.evm.console.local.paging=TRUE".
- -v or -verbose: This causes messages to be displayed by the EVMConsole when a class file or dynamic library is successfully loaded or when a garbage-collection cycle is performed.
- -version: Displays the EVM and class library versions.
- -Xnowinceconsole: This option disables the EVMConsole if you don't want it to remain visible while running graphical applications.
You can further test your installation by trying out all the test applications found in the Examples and AWT folders.
I think I've done enough talking about what can be done with Java on the iPAQ, so let's put theory into practice and build some simple applications. We'll be building both a console and a GUI app that uses AWT. I'll be building Java applications that are Java 1.1-compliant, so if you're using a current IDE based on Java 2, you'll need to utilize its JDK switching feature to compile against JDK 1.1. In some cases I'll package the Java apps in JAR files - in this case, either use your IDE's JAR wizard or JAR your classes together at the command line.
Console App
The console application we develop will demonstrate multithreading and reside in a package called "basicconsole" and consist of two classes. The code for the class called "counter" is shown in Listing 1.
This class is the worker thread that simply counts upward from one number to another based on the integers that are passed into it. It sends those numbers to the console. The main class is called "app" (see Listing 2).
When this class executes, it creates two threads, passes them the number ranges, assigns thread names, then starts them.
After successfully compiling and testing these classes on your desktop computer, you need to JAR them up in a file called "BasicConsole.jar". The next step copies this JAR file to your iPAQ.
With an open ActiveSync connection, click the ActiveSync Explore icon to view the file structure on your iPAQ. I suggest you copy your JAR file to the "My Pocket PC" folder so you won't have to type in any path arguments to launch your application (see Figure 2).
Figure 2:
To try out this console application on your iPAQ, bring up the Jeode console and type in "-cp BasicConsole.jar basicconsole.app", the result of which is shown in Figure 3.
Figure 3:
Of course, there's not much demand for console apps anymore, so let's build that AWT application. Keep in mind that when using your latest and greatest Java IDE, it may insert all kinds of Swing references that you'll have to delete to create an AWT application that's compliant with JDK 1.1.
AWT App
The AWT application we build will also demonstrate multithreading, reside in a package called "basicawt", and consist of two classes. The code for the main class, called "app," is shown in Listing 3. (Note: It's rather obvious that JBuilder has been used to generate this code.)
The second class is the actual Frame that will display our GUI elements. This class is called "frame1" (see Listing 4).
The Frame loads and displays two buttons and two text boxes. Clicking on either of the buttons will spawn a thread that starts counting from one to 200. This counting will go by almost instantaneously on your desktop but will take a little more time to execute on your iPAQ.
After compiling and testing this app on your computer, JAR it up into a file called "basicawt.jar", then copy it to the same "My Pocket PC" directory that you copied your console application to. To try out this AWT application on your iPAQ, bring up the Jeode console and type in "-cp basicawt.jar basicawt.app". Figure 4 shows what this application should look like.
Figure 4:
(Note: Clicking on either of the buttons will trigger the counting race that's displayed in the corresponding text boxes.)
Keep in mind that this is just the tip of the iceberg when working with AWT. You can display images, check boxes, panels, combo boxes, labels, scrollbars, menus, and much more. That being said, if the AWT was so cool, why was it replaced by Swing? I can't argue there, but I do have a suggestion. Sitraka Software (formerly KL Group) allows you to freely download their pre-Swing GUI components from www.sitraka.com/software/jclass. These JavaBeans make a great replacement for AWT and even rival Swing with components that include tree views, tabs, multicolumn list boxes (grids), progress meters, sliders, spinners, and windows splitters, to name a few. You can easily put together a pretty slick GUI (see Figure 5).
Figure 5:
Now that you know what can be done with Java on the iPAQ, let's wrap up with one more note on the deployment of your applications. You can imagine that the average user won't be interested in launching his or her Java apps by typing commands in the Jeode console. Luckily, there's a better way through the use of shortcuts.
Start out by creating a text file on your desktop with a descriptive name like "BasicAWT.txt". Now change the "txt" extension to "lnk" to turn it into a shortcut. Open this shortcut in Notepad and type in text similar to what you typed in the Jeode console. To launch your BasicAWT application, the text on the first line of your "lnk" file will look like "1#\windows\evm.exe -cp basicawt.jarbasicawt.app". All you have to do now is save and copy this file to your iPAQ in the \Windows\Start Menu directory. From now on, you'll see the Jeode icon along with "BasicAWT" listed on the menu that you pull up from the Start button.
Congratulations! You've gone from learning about PersonalJava, to installing the Jeode VM and building and deploying your own Java apps. I hope you've enjoyed this glimpse into the world of Java on the iPAQ. Good luck in your development efforts.
Author Bio
Rob Tiffany is vice president of technology for True Quote (truequote.com), an online energy trading company. He has published numerous articles for a variety of magazines on topics ranging from Java servlets to wireless technologies. Rob is the author of Pocket PC Database Development with eMbedded Visual Basic from Apress.
- Sync Services for Windows Mobile Devices has Shipped!
-
Hello all,
Just wanted to pass along that the device bits for Sync Services for ADO.NET have been released to the web! Now we have a supported version of Sync Services for Windows Mobile 5.0 and 6.x. You can find the download at http://www.microsoft.com/downloads/details.aspx?familyid=75FEF59F-1B5E-49BC-A21A-9EF4F34DE6FC&displaylang=en. Keep in mind that you’ll also need SQL Server Compact 3.5 Service Pack 1 for Windows Mobile at http://www.microsoft.com/downloads/details.aspx?FamilyID=fce9abbf-f807-45d6-a457-ab5615001c8f&DisplayLang=en as well as Visual Studio 2008 SP1 which can be found at http://www.microsoft.com/downloads/details.aspx?FamilyID=fbee1648-7106-44a7-9649-6d9f6d58056e&DisplayLang=en. This sync technology is a developer-focused companion to Merge Replication that can take advantage of the more efficient change-tracking engine in SQL Server 2008. Since it’s based on a higher-level ADO.NET Provider model, you can also get it to sync your device with other databases like Oracle and DB2. This technology should break down some barriers for us so we can deploy Windows Mobile and SQL Server Compact in organizations that don’t support SQL Server.
Best Regards,
Rob
- The Blackjack II is Ready to be Managed by System Center Mobile Device Manager
-
Run, don't walk out to http://www.samsung.com/us/i617/windowsupgrade and upgrade you Samsung Blackjack II to Windows Mobile 6.1. Make an already great phone even better with threaded text messaging, a translucent, sliding panel home screen, better battery life, more efficient OTA Exchange ActiveSync, Office Mobile 6.1 with support for Office 2007 file formats, and Internet Connection Sharing.
But wait, there's more...
Windows Mobile 6.1 was built to set it apart from all other Smartphone/PDA competitors by taking its Enterprise capabilities to the next level. Your Blackjack II will now be able to join your company's Windows Domain and access corporate line of business applications from the Internet via an optimized Mobile VPN. System Center Mobile Device Manager will be able to push software to your device, encrypt your phone and enforce corporate policies.
If that's not enough, AT&T has included mission-critical games including Solitaire, Brain Challenge, Bubble Breaker, The Sims Bowling, Midnight Pool, and Ms. Pac-Man.
With Windows Mobile 6.1 running on your Blackjack II and System Center Mobile Device Manager running in your data center, you'll have the option of Blacklisting those games to keep your mobile employees focused on business if you need to. It's a no-brainer
- Rob
- Sync Framework v1 and Sync Services for ADO.NET v2 are now Generally Available!
-
As of today you can download the Sync Framework SDK in 11 languages including Chinese (Hong Kong), Chinese (Simplified), English, German, French, Italian, Japanese, Korean, Portuguese, Russian and Spanish for AMD64, IA64 and x86 processors from the Sync Framework Download Center.
What is Sync Framework?
Imagine being able to build a solution that seamlessly exchanges contact information between Outlook, a database contact management application, your mobile device and your service based contact management system. Or how about a mobile device that connects with other devices to exchange pictures and videos. How about being able to take data from any of your enterprise databases, file or enterprise systems and make it available offline for users to modify and sync back up to the enterprise. All of these capabilities are possible with the Sync Framework and best of all, it is free on Windows platforms and licensable on non-Windows platforms!
Just a few examples of companies that are already using the Sync Framework include:
- SmugMug who has added support for the Sync Framework to enable developers to build rich offline applications that can allow photos to be easily shared on friends and families local computers.
- InterScape have embedded Sync Framework into their Customer Relationship & Management (CRM) solution to enable sales people to synchronize enterprise files and data for offline access.
- Fujitsu Siemens will embed the SyncToy file synchronization solution (powered by Sync Framework) on their STORAGEBIRD external drives to enable seamless file synchronization between devices and computers.
Sync Framework Highlights
Some of the highlights of this release include:
- Sync support to new and existing applications, services, and devices
- Collaboration and offline capabilities for any application
- Roam and share information from any data store, over any protocol, and over any network configuration
- Leverage sync capabilities exposed in Microsoft technologies to create sync ecosystems
- Extend the architecture to support custom data types including files
Sync Services for ADO.NET v2 Highlights
Sync Services for ADO.NET is a Microsoft Sync Framework powered solution for synchronizing ADO.NET enabled databases in offline and collaboration scenarios. Sync Services for ADO.NET allows developers who are familiar with the concepts of ADO.NET to apply that knowledge to data synchronization through a very similar set of APIs to that of ADO.NET. Sync Services for ADO.NET provides the flexibility of a programming model like offline datasets and a richer synchronization feature set like that found in Merge replication. Sync Services for ADO.NET also supports synchronization over services, such as Windows Communication Foundation (WCF).
Some of the Sync Services for ADO.NET highlights include:
- Offline Database Synchronization: With Sync Services for ADO.NET you are able to build a solution where multiple remote clients connect and synchronize to a central ADO.NET database in a Hub-and-Spoke configuration. This enables occasionally connected devices to periodically connect and synchronize changes with a central ADO.NET database server. This topology is a common solution for remote workers such as sales reps or field service workers.
- Collaboration Between Databases: Sync Services for ADO.NET also includes Peer-to-Peer capabilities. Through a custom Peer provider, collaboration between two or more SQL Server databases can occur (support is not available for SQL Server Compact). Unlike a Hub-and-Spoke architecture, this provider enables a SQL Server database to communicate and exchange information with any other SQL Server database. This type of scenario is useful in group scenarios where users (such as auditors) need to update information and then collaborate those changes with other group members.
- SQL Server 2008 Integrated Change Tracking: If you are using SQL Server 2008, we recommend that you use the SQL Server change tracking feature. This feature addresses many of the issues of custom-tracking systems and provides a straightforward way to track changes. Change tracking is also supported by the Local Database Cache in Visual Studio 2008 SP1. Developers can now specify that the Configure Data Synchronization wizard should enable SQL Server change tracking on the server and generate the commands necessary to select and apply changes to the server database. Unlike custom change tracking systems, SQL Server change tracking does not require any schema changes in the server database. For more information, see the Visual Studio 2008 documentation.
Sync Framework Pricing
Sync Framework will be licensed free on Windows platforms. In addition, we are also licensing the specifications and a source code porting kit to developers who want to implement Microsoft Sync Framework solutions on non-Windows platforms.
To learn more, visit http://msdn.microsoft.com/sync
- Rob