Developing J2ME CDC compliant application using Creme JVM, Swing and NetBeans IDE for Windows Mobile Devices PDF Print E-mail
Written by Felipe J A P Mattosinho   
Wednesday, 21 July 2010 20:07

1. Introduction

Have you ever heard about J2ME CDC?  Sun defines two different configurations when programming JAVA J2ME.The first one is called CLDC (Connected Limited Device Configuration), and the other one CDC (Connected Device Configuration). I will skip some details of both configuration, and if you want to know more about it, you can find lots of information on Sun web site.

For now, a simple and sufficient explanation for both configurations are: The CLDC is basically what we are used to see in the majority of cell phones. Most of them use this configuration, as the name suggest for "limited" devices. This configuration is intendend to phones with low memory and processing power capacity. In the other hand we have CDC. CDC aims to support smartphones, pdas or cell phones with higher processing power. The feeling that we have programming a CDC application, is almost the same as programming a normal java desktop application. Among several CDC compliant JVMs,  this article will show one of them, called CreMe Virtual Machine. This JVM runs under Windows Mobile and its big advantage is the possibility to use Swing for building you GUI. This Virtual Machine was the most stable and reliable that I tested so far(during a project that I was part of), however it is not free and you are allowed to try it for 30 days. Finally, let's move on. I'll show how to set up an evironment for creating mobile applications using Swing and Creme JVM.

2. Setting up the environment & Requirements

  1. Netbeans IDE with Mobility Pack
  2. Microsoft Activesync
  3. Creme Developer Kit V4.12
  4. Creme JVM 4 (Remember to select the appropriate processor and windows mobile version when downloading it)
NOTE: When installing the Creme JVM remember to connect your phone before. Double click on the executable file and the installation file should take care of everything.If by the end of installation your receive the screen shown in fig 1, you don't need to worry.Just go to the following folder "c:/program files/microsoft activesync/nsicom/" and you should find three files. Copy the .cab file to your phone. Now in your phone, browse to the file, double click it, and the installation will automatically start.After the installation, if you wish, you can delete the cab file.

Error screen

 

Now you should perform a last step. Go to the following folder in your pc: "C:\Program Files\NSIcom\CrE-ME V4.12\lib" and copy the file swingall.jar to the following folder in your phone "windows\creme\lib".Without this library on the phone, any application written using Swing will fail to work.

Hint: Remember to select the option "show hidden files and folders", in windows explorer. The folder windows in the phone is hidden by default.

After installing all of them, let's start setting up a new platform to work with NetBeans.

Start your NetBeans.

1-Tools → Java Platforms

Screen 1

 

2-Click on "Add Platform" , select "Java Me Cdc Platform Emulator" and click "Next".

Screen 2

Screen 4

3 - The next screen asks the path to the folder. You should select the folder where your Creme Developer Kit is installed (the default folder is c:/program files/nsicom/CrE-ME V4.12) and click "Next".

 

Screen 3



Starting with the first application
Go to File-> New project

4 - Now select the platform (by default is called:"pJSCP V4.12 B142.190307").  Click on "Finish" .

 

 

Screen 5

Your new platform is now added to NetBeans. Now we are ready for our "Hello World" program .

On the "Choose Project" panel, select mobility (left panel) and CDC Application (on the right panel called "Project") .Click Next.


Hello World 1

 


Now give a name to your project (e.g "Hello World"). Click Next.

 

Hello 2

The next screen , asks for a Java Platform

Hello World 3

Make sure that the following configuration is applied.

Java Platform: pJSCP V4.12 B142.190307
Device: Default
Profile: PP-1.0


Click "Finish".

Your project is now done!

5. Testing the application

After all this steps, let's create a very simple code, to show two different ways to run our application.
Now you should see a form in the central panel of NetBeans.(if you see it , the "design" view is selected, otherwise should be on "source" view mode as shown:

Hello World 4


On the right, select a jTextField and two jButtons, located at the bar named "Pallete".
Name the buttons "Exit" and "Hello World".
Add the both to the frame. Double click the button, and add the source code

jTextField1.setText = "Hello World" as shown in Fig 11.</p>

HINT: Creme Virtual Machine does not provide a form, with some usual windows functions like the close(exit) button, minimize and maximize.  That is the reason why i suggest to create the "Exit" button, with the code
System.exit(0);
Now just run it. Your application should be running well at NetBeans IDE.</p>

HINT: Creme Virtual Machine, runs very well and stable. However it is easy to realize, that the graphics are bad. My suggestion is to change them whenever possible, by your own graphics (e.g png, gif or jpg images).

Hello World 5

4. Testing the software remotely

The second possibiliy for running and testing your applications, is doing it remotely.
Yes this is possible, and makes life much easier.By simply clicking the run button in NetBeans you should see the program running directly in your phone.
First make sure that your mobile is connected to your computer, and properly communicating(Microsoft ActiveSync should be activated).
Click with the right button in your project, and go to Properties. </p>

 

<p class="fign">Fig 1
<p>On the following screen(Fig 13) select running , and then click on the tab "NSIcom".
check the "Run in remote VM" box and click ok.</p>
Hello World 6

Now press the run button in NetBeans IDE, wait for a while and your program should automaticaly start in your phone.

Hello World 7

An application example
Here you can see 2 screenshots of an application that i made, running on my Smartphone. It is possible to realize, on the top of it, a grey menu bar, as well as labels, textboxes, and buttons. As i said before, i realized that the default graphics from creme look very bad, so i decided to change everything for my own graphics. The second picture, shows even more Swing components, as for example a tabbed menu.

Custom Application Screen 1

Labels , backgrounds and buttons. Graphics can be modified, if you don't like the default grey from Creme

Custom Application Screen 2

Last Updated on Monday, 26 July 2010 23:38
 

Comments  

 
0 #7 Gaz 2010-08-03 12:52
Sorry for the delay, had a reformat since and lost links!\r\n\r\nF elipe, thanks for your reply, I am uncertain of which JVM supports CDC on Windows Mobile Pro 6.1 and also which files I need to copy over for deployment. I think I have been using JVM\\''s that only support MIDP stuff so they look for midlets. Also, do I need different packages on my phone for PProfile and AGUI support?\r\n\r\nYour help much appreciated thanks.\r\nGaz
Quote
 
 
0 #6 Administrator 2010-08-03 12:05
Quoting Gaz:
Great lesson thanks, but how do I deploy it properly to my phone please. I am struggling!

Thanks
Gaz


Hi Gaz, What type of problems are you finding to deploy it?!
Quote
 
 
0 #5 Gaz 2010-07-30 22:28
Great lesson thanks, but how do I deploy it properly to my phone please. I am struggling!

Thanks
Gaz
Quote
 
 
0 #4 Mayara Madeira Trevi 2010-07-30 22:27
Muito obrigada Felipe!!
teu artigo salvou minha pele
ehehehehe

parabéns, otimo tutorial!
Quote
 
 
0 #3 Pragun 2010-07-30 22:26
great article !

I realize that swingall.jar now comes with creme4.12 installation. Besides that I tried all exectly what you said and it worked very well.
Quote
 
 
0 #2 Denilson 2010-07-30 22:25
Congratulations ... Very nice article. Thanks for information!!
Quote
 
 
0 #1 John Ireland 2010-07-30 22:24
Well done Felipe. Got it working finally thanks to your article. Muito Obrigado!!
Quote
 

Add comment


Security code
Refresh