Friday, June 19, 2009

J2ME Http Tester Application

Http Tester

Blackberry Experience

Lately i have been involved in working on a J2ME application which runs on sprint network. This application was built for a Motorola handset and i was asked to make some feature enhancements. So far so good. I have delivered the build and everyone is happy.

Now i have been asked to port this application to a blackberry device and here come the worries. This phone has OS of version 4.6.1

1) File handling issues.
http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=40896#M40896

The way files are organized in blackberry is quite different that other J2ME handset. It took me a while to figure out where can i look at the file created by the application. I was using /home/user as the URL. It seemed to work fine on the emulator as in the application i was able to see that i have been successful in writing to a file and from other part of the application i was able to read the content. But on the device it was throwing Security Exception.
It took me 3-4 days and countless google search to realize that you need to sign the .cod file using blackberry signature tool before it is usable at the device. So if someone who is new at blackberry and trying out file handling don't forget to sign it.
Now to look at the file you have created. Click on the option button from main menu. Now select folder "media". Selection option button again and pick "explore". Now you will see "DeviceMemory". Inside device memory there is "home" and inside "home" you will see "user" folder. You see it is not so easy to find this directory.

2) HTTP Connection issue.
In this application i post some data to a server (php page) and then read the data returned by the server. It works perfectly fine on the emulator and motorola handset. So there must be something special needs to be done at blackberry. If you have solved it please drop a note. I have posted it at blackberry forum too.

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&thread.id=43155