Tuesday Mar 28, 2006

CDC platform from Sony Ericsson - installing and using

When you need a platform for the NetBeans Mobility Pack 5.0 for CDC you can use the Sony Ericsson CDC Platform. I had lot of troubles when I tried to install it first time but when they were solved it worked. I unistalled it from my computer. I will try to install it again and describe the bottle necks. Here we go.

What you have to download
You have to download a few installers for the CDC platform.
Install the UIQ
The first question dialog that you'll see when you start the UIQ3SDK.exe installer is a little bit strange. Aren't we installing UIQ SDK?

Click Yes, of course. The UIQ SDK needs a Perl. You have to install it. When the Perl is installed you have to run the UIQ3SDK.exe installer again. Finally, the UIQ SDK installation starts. The installation needs almost 700MB on your hard disk. There are only UIQ Pen Style and UIQ Softkey styles of emulators available when the installation finishes.

We have to add a support for CDC to the UIQ SDK now.

Install Sony Ericsson CDC Platform 1 Extension Package
Run the installer (semc_cdc_platform_1_beta_0_4.exe). Choose the location of the UIQ SDK. It's necessary to select the directory one level up epoc32 directory. The installation requires about 27MB on the disk.

Install the extensions
Then you'll have to install M600 Extension Package (semc_m600_sdk_extension_beta_0_2.exe) and P990 Extension Package (semc_p990_sdk_extension_beta_0_2.exe.

This provides P990 and M600 support including Sony Ericsson APIs and other attributes. We can now use the M600 and P990 emulators.

Install NetBeans Mobility Pack 5.0 for CDC
First install NetBeans 5.0. If you already have NB 5.0 installed you can install Mobility Pack 5.0 for CDC to the installed NetBeans 5.0. The installer should suggest the right directory of the existing NB 5.0.

Select a style
This step is necessary before you can use the SE UIQ CDC platform in IDE. You have to run SDKConfig.exe and set the style (emulator) that you want to use. You can change this setting from the IDE later.

Follow the post installation steps from NetBeans Mobility Pack 5.0 for CDC Quick Start Guide. I'll copy the steps here: Let's assume, your installation is located in folder F:\\Symbian\\UIQ3SDK_BETA3\\
  • Open command line window
  • Issue set EPOCROOT=\\Symbian\\UIQ3SDK_BETA3\\  Note the opening and closing backslash characters
  • Issue set SDKDRIVE=f  Note the : is not there
  • Invoke F:\\Symbian\\UIQ3SDK_BETA3\\epoc32\\tools\\distrib\\SDKConfig.exe  go to Styles tab, select M600 CDC or P990 CDC skin and press Apply Style button. It takes several seconds to install all necessary file to correct location
  • You can verify installation by looking into folder F:\\Symbian\\UIQ3SDK_BETA3\\epoc32\\tools\\ppro-custom-launcher\\ where you can see following files: compile-rss.bat, custom-app.bat, LauncherUtils.exe
It happend to me that I changed the style and nothing happend. The were no files in the dir F:\\Symbian\\UIQ3SDK_BETA3\\epoc32\\tools\\ppro-custom-launcher\\ or the directory was totally empty. Try to switch the styles there and back. It will work on next try. It only strikes sometimes... (it is only beta) It helped me to switch to M600 and back to M600 CDC.

Add CDC platform to IDE
Run NetBeans IDE. You can add the CDC platform either when creating first CDC project

or from main menu Tools | Java Platform Manager | Add.... Select the option Java Micro Edition CDC Platform Emulator.

Select the UIQ SDK installation directory and IDE should recognize the platform. If there is message "Platform is not correctly set up. Use SDK Configuration Tool to set up correct emulator style." then exit the dialog. Try again the Select a style step and then you should be able to add the CDC platform to the IDE.

You should be able to install the Sony Ericsson CDC platform following the previous step. You should be able to add the platform into the IDE and create new project.
There can be problems with adding the CDC platform to the NB first time. The problems can be usually solved when switching the styles in SDK Configurator run from command line.

The first start of CDC emulator takes usually looooong time. Be patient.

Tuesday Mar 07, 2006

Simple example of WaitScreen component

There is WaitScreen component () in the Palette of the Mobility Pack when you are working in a Visual Midlet. This component is available only for MIDP2.0 and Visual Midlet in MIDP 2.0. It is designed for run of longer tasks that can block UI in background. The task will run and you will see the WaitScreen with a text or image. When the task finishs then it continues on next screen. There is SimpleCancellableTask non-visual component for definition of the task for the WaitScreen. You can find the SimpleCancellableTask in Resources in Palette. Drag and drop it into your Visual Design MIDlet.
Open Properties of the new SimpleCancellableTask and you can define Executable Method Body. The Executable Method Body is the code that will run on the background when the WaitScreen appears on the screen of the device. Note that the WaitScreen can end either with Failure or with Success. When the SimpleCancellableTask ends without an exception then it will continue to the Success screen otherwise it will go to the Failure screen.

I created a simple example that connect to internet and shows a price of a stock. I reused some codes from QuotesMIDlet.java

The main problem that found when I was creating the example was that the simpleShockPriceTextBox component is created and used in setNextDisplayable method of the WaitScreen before the data are downloaded from network. I had to add call of setString(...) of the showShockPriceTextBox at the end of the Executable Method Body of the SimpleCancellableTask. It updated the value correctly.
I tried a different approach before. I set showShockPriceTextBox=null and hoped that it will re-create the component again with the right values but it didn't worked in that way :(


[TIP] Setting proxy server for WTK

When you are behind firewall/proxy you will have to set proxy for your emulator. You can do it from the IDE directly. Either open project properties and then press Manage Emulators... or open Tools | Java Platform Manager.

Select the WTK platform that you are using and go to Tools & Extensions tab. You can setup some emulator settings here. Click Open Preferencies. Preferencies dialog appears.

Fill the proxy server address and port. Click Close. Click OK.
The proxy server for WTK platform emulator is set up.

Friday Feb 17, 2006

[TIP] Reusing Commands in Visual Mobile Designer

Programming for mobile device is hard. There are resctricted resources. You can save a few bits of memory with reusing commands. Every variable counts ;)

All the commands that you've added to a MIDlet are visible under node Commands in Inspector. You can reuse a command on particular screen in this way:
  1. Expand the screen node (e.g. form1) in Inspector
  2. Right click the Assigned Commands
  3. Select a command from Add | yourCommand
  4. you can even add new command

Lookt at the picture on right. It's self descriptive.

Unfortunatelly, there isn't a simple visual way how to do.
I proposed RFE about a pool with all reusable components like fonts, tickers, commands, images for your MIDlet. It could be visible somewhere and you'd just drag'n'drop the reusable components form the pool in the same way like it works with palette. They (developers) closed it :( Reason: "this could result into the FlowDesigner in "too-many-components-on-the-screen" state". Hehe, I reopen it again ;) It could be a new category in palette and it would be even more obvious. What do you think?

Thursday Feb 16, 2006

Problems with Motorola J2ME SDK v5.3.1 and Mobility Pack 5.0

You can download the Motorola J2ME SDK v5.3.1 from motocoder.com. There are two major problems with this emulator platform in NetBeans Mobility Pack 5.0.
First is name collision when you are adding this platform. Second is that you cannot switch the device. I'll show how to solve it. Well, maybe better term is how to work around it. Install the SDK at first.

Adding the Motorola SDK platform
You can add the platform in Tools | Java Platform Manager | Add Platform... | Java Micro Edition Platform Emulator. The IDE will find your installed SDKs.

Click Next and there is the problem. The collision in names of the platforms. Well, it's caused by Motorola SDK. It returns the same name "MicroJblend" for both platforms A.4, A.3

The solution is simple. Rename one of the platforms in the collision to a different name. E.g. MicroJblend2 ;)

Switch Device
Don't be suprised that nothing happens when you change the device in Project Properties. The problem is noticed even in Motorola's release notes - "Changing the device in Netbeans using UEI is not working currently. Workaround – Start the MIDlet in the Launchpad selecting the desired device. All subsequent launch will use this device until this procedure is repeated". This is unfortunatelly true. You have to use the Motorola's LaunchPad. Please, do it before you run Motorola's SDK from IDE. If you don't do it then the emulator start and closes immediatelly.

Friday Feb 10, 2006

[TIP] Repair WTK after reinstallation of JDK

Java Development Kit(JDK) is evolving and they release new version of the JDK quite often. It's obvious that you want to install the latest JDK with new fixies and uninstall the old JDK. Unfortunatelly, your Wireless Toolkit (WTK) stops work when you uninstall the old JDK. The reason is that the path to the JDK installation directory is hard-coded in the WTK's scripts. This problem occures only with WTK that you installed by yourself. We solved it for the default WTK that is bundled with NetBeans Mobility Pack. The scripts in bundled WTK are changed automatically.

Problem symptoms
You see a message like the one below when you run a project using the broken WTK as the platform emulator in the NetBeans Mobility Pack.
Starting emulator in execution mode
\\nbproject\\build-impl.xml:295: Execution failed with error code 1.
BUILD FAILED (total time: 1 second)
You cannot run the emulator even from command line.

Fixing the Broken WTK Installation
You can easily recover from this situation if you change the JDK path in the WTK scripts for existing JDK installation directory. You will have to change the path at least in these three files in bin directory in the WTK installation directory:
  • emulator.bat
  • prefs.bat
  • utils.bat
Open the files in any text editor and replace the path to uninstalled JDK with the path to the newly installed JDK. Your Wireless Toolkit then starts to work again.

This TIP describes how to fix it on windows platform. The process is almost the same on linux. There is javapathtowtk defined in those three files. Change it to the new installed jdk.

This article has been published even on netbeans.org. You can find more details there - http://www.netbeans.org/kb/articles/fix-toolkit-installation.html.
More tutorials about Mobility Pack - link

Sunday Feb 05, 2006

[TIP] Switch from 4.1 to 5.0

I tried to switch from my NetBeans Mobility Pack 4.1 to the new 5.0 release. I'll describe what you can expect from this step. I closed my old NB 4.1 I installed the new NetBeans 5.0 and the Mobility Pack (you can download both here). When I run the NetBeans 5.0 this dialog appeared

I answered YES, of course. The dialog doesn't appear next time when you answer NO. The NetBeans Mobility Pack started.
All my projects that I worked on in 4.1 were listed again in the Projects view. Exactly as I expected ;)
When I look at Tools > Java Platform Manager then all my emulators platform were transfered successfully too.

When I build/run the projects then everything works too.

What changed for me? What is the difference?
I can use all the new features from Mobility Pack 5.0 right now - look at my previous post where they are listed. There are even all the new features of Netbeans 5.0, of course.

What should I be careful of?
The format of generated code changed for Visual MIDlets. It doesn't mean that you should create everything again from start. NOWAY. When you open a midlet that is in the 4.1 format then following message appears

Don't be afraid and click OK. The visual midlet opens in Flow Design and everything should look exactly the same as in 4.1. When you look at Source code you'll see the difference. The one big guarded block was splitted and you can write your code into the unguarded parts of source code. It means that you won't need any Property Editor for the pre/post code anymore. You can write it directly into the source code. If you don't know where is the right place for your code use Go to Source feature in Flow/Screen Designer. All these changes aren't saved yet. If you don't want to save your file in new format then Discard the changes. If you'll accept the changes and save the file in 5.0 format then you cannot open this visual midlet in NB 4.1 anymore!

Preprocessor block definition changed too. The old syntax works anyway so you don't have to change it to the new syntax immediatelly. You can leave it in the old syntax. There is suggestion on left sidebar that appears when you are on the line with old syntax. Look at the picture.

You can use the suggestion to change the old syntax to the new one.

Do you see the small difference? You can create new preprocessor block from context menu as you used to in 4.1. Second way how to create preprocessor block is start to type definition of preprocessor block directly into the source code. Try type //# and code completion with available preprocessor directives appears.

When you change the active configuration then there are commented and uncommented preprocessor blocks. You maybe noticed that the prefix of inactive preprocessor block changed to //# . The prefix was //-- in 4.1 You can be suprised that when you close the file and look at the file on your hard disc then you'll still see the old syntax. CVS diff doesn't show any change too. Why? The file is always saved in DefautConfiguration. The main reason for it is the CVS. All users save file in same configuration and therefore they are not suprised be unexpected diffs.
The new prefix will be saved only for changed or new inactive lines.

Your settings and setup should be imported into 5.0 automatically when you use the default userdirs (no --userdir command line switch).
Projects from 4.1 should work in 5.0 without any change.
Be carefull that you cannot use some code from 5.0 in 4.1 again...

Sunday Jan 29, 2006

[TIP] Download WTK from SDK catalog

There is new easy way how you can download new WTK with NetBeans Mobility Pack 5.0 now. There is new Update Center called Java ME Platform SDK Catalog. Go to Tools | Update Center and let selected only Java ME Platform SDK Catalog. There are two builds of Wireless Toolkit available now - 1.0.4_02 and 2.3beta. When you download the platform then it is automatically installed to your computer and added to the available platforms in NetBeans.

I expect then there will be more platforms available later.
Note: when you are on linux please be sure that there is uuencode available

Saturday Jan 07, 2006

Blackberry Development Using NetBeans Mobility

This article will provide you all infomations that you need for developing an application in Mobility Pack 5.0 for BlackBerry's devices.

You need only RIM Blackberry JDE 4.1 and NetBeans 5.0 with Mobility Pack. Set up your enviroment like in the article and you are ready to develop.

Well, some users asked interesting questions on mailing lists. The answer are here:
  • your midlet will appear among the others application in the BlackBerry desktop. I was confused first time before I fount it and found out how to select it. Look at the screenshot on the right side. My midlet is in surrounded with red color.
  • I still don't know how to add icon to my midlet. I found that it has to be 28x28 pixels but I give it up ;)
  • Use BlackBerry development forums for questions about development of application for BlackBerry
  • An Introduction to BlackBerry J2ME Applications - this might be interesting reading

Thursday Dec 08, 2005

[TIP] Save Flow Design to PNG file

You created really nice application and your college want to see the work flow of the application. You can send him screenshot of the Flow design and you don't have to even left NetBeans now. Just right click on background in Flow design area and select "Export Flow Image" from popup menu. PNG file will be generated into desired location.

re-design the layout of Flow design before export.

this feature is available in Mobility Pack 5.0 from Beta 2 build

This is the main channel to share news, tips and other stuff related to my work. Sometimes you can find even personal stuff. Enjoy your reading...


« June 2016

No bookmarks in folder