If you are developing a J2ME application that connects to the Internet and are using a Mobile Emulator then you will invariably have to put up with the repeated messages that ask if it is OK for your phone to use Airtime (i.e. connect to the Internet). Not only is this very annoying but it also has the potential to prevent proper automated testing from being carried out.
This actually happens when your application has not been properly signed but only seems to happen in the Emulator (it does not happen on my Nokia E70). Until now, I was of the impression that the only way around this was to purchase a full digital signing pack from the likes of VeriSign etc. Gladly, this is not the case …
We overcame this problem using the latest Sun Java Wireless Toolkit and NetBeans as follows:
- Start the Sun Java Wireless Toolkit “KToolbar” application and select Edit, Preferences
- Locate the Security category and select the following settings
- Security Policy: MSA
- Security Domain: manufacturer
- Save these preferences
- From your NetBeans project, select the project properties.
- Locate the Signing settings (inside the Build settings) and select the following settings:
- Sign Distributon: Yes (or checked)
- Keystore: Built-in keystore
- Alias: untrusted
- You might also need to Export this key to the Java SDK/Emulator using the button provided
- Save these settings and rebuild your project
Hopefully the next time you launch your application from the emulator will no longer ask permission to use Airtime.
Nokia’s Carbide.j has a Nokia Forum certifate you can use to sign your app too, just for testing of course. Makes it pretty painless and includes cool stuff like on device debugging over wifi.
http://www.forum.nokia.com/main/resources/tools_and_sdks/carbide/index.html
It does not work,i made the setting for Netbeans IDE 6.1 exactly like that but it still ask the permission.Can you help me out?Thanks
Hieu,
Even though this post is almost 2 years old now and the version of NetBeans used was 5.5, the above instructions still appear to work well for me with Java Wireless Toolkit 2.5.2 and NetBeans 6.01.
I created a new Mobility project in NetBeans (MIDP Application) and choose all of the default options. Then, I inserted some HTTPConnection code (see below) into the getStringItem method:
As expected, as soon as I ran the MIDlet, I saw the “OK to use Airtime message”. I then changed the Preferences in the Java Wireless Toolkit as well as the NetBeans properties (according to this post) and the “OK to use Airtime” message went away.
I noticed that if I changed the Preferences in the JWT back to “Security Domain: identified_third_part”, and rebuilt my mobile project again, the message re-appeared. I think it is important that you clean and rebuild your project after you change the settings in JWT.
Can you try something similar to this and let me know if you still have problems?
Peeeeeerfect solution!!!!!, thanks
I’m from Chile, South America…
Great post:) Works fine:)
Hi Friend…
I used the same for running it successfully for one J2ME project.. but when I use J2ME polish its not allowing me to proceed further.. is there any extra step involved.. please advise…
Hey Friends…
I got the answer…
we have to start it in a separate thread than the one which we use for display….
Hurray… :-).. Have a nice time Guys..
Yes, this is a common problem with J2ME – it relies heavily on the use of threads for many tasks. You should also read this other article I posted on Alerts in J2ME as it was also solved by the introduction of threads.
where do i change the Preferences in the JWT i am not able to fing JWT in my netbeans6.5 please help me
yes,i got it. but now i have a problem where i am not able to insert values into database through servlet can you help me out
thanks in advance
Santu,
As you probably figured out, the JWT settings are not modified from within NetBeans but rather from the Sun Java Wireless Toolkit menu on the Windows, Start, Programs menu.
I’m afraid your second query is too vague to help you with – you have not provided any information about what technologies you are using, and when using servlets and databases with servlets, there any many, many choices. Therefore, this is not really something I can help you with.
I would suggest that you try to find some user forums for each of the technologies you are using and look for help there (i.e. MySQL, Tomcat, JBoss, Hibernate and others)…
hi,
How Start the Sun Java Wireless Toolkit?
I unknown how start it, please help to me
This depends on your operating system. If you are running on Windows, there should be a Program Group called “Sun Java Wireless Toolkit” under the Start, Program menu.
If you are running on Linux or another flavour of Unix, I think there is a binary program in the ‘bin’ directory where you installed the software. I could be wrong about this though as it has been some time since I used it on Unix.
hi Mernin,
I download ‘Sun Java Wireless Toolkit’ and setup on computer and set ypur setting on netbeabs and toolkit, but i have ‘OK to use Airtime’ ๐
when i run project in NetBean and view Mobile Emulators, netbean give to me this message in output panel :
“Running with storage root DefaultColorPhone
Warning: To avoid potential deadlock, operations that may block, such as
networking, should be performed in a different thread than the
commandAction() handler.”
I want only read ‘http://127.0.0.1/a.xml’ with
StreamConnection c = (StreamConnection)Connector.open(URL);
or
HttpConnection c = (HttpConnection) Connector.open(URL);
Please help to me,
Thank you, thank you!
From Belo Horizonte, Brazil.
Saeed,
I don’t currently have a copy of NetBeans installed but there are several others on this thread for which these settings do work so perhaps you’ve missed something in the setup.
The other message about “to avoid potential deadlock” is a fairly common problem that people encounter when they are new to J2ME programming. What it is telling you is that you need to perform any network access in a separate thread. The reason for this is that when you try to establish a network connection, user input is suspended and none of the keys on the phone will work. This could mean that if you see the “OK to use Airtime” message, then you will not be able to answer “Yes” or “No” because the input is suspended.
There are plenty of examples on the web showing how to run your network access code in a separate thread.
Hopefully this will help you.
hey, i very recently started developing J2ME applications, i have downloaded WTK and JDK and ran some basic applications,tey pretty cool,. could you tell me about some useful web resources for developing mobile bill payment systems.(i am looking for a beginners level of coding, but any comment from you is welcome)
Thank you for your positive comments about this article. It has certainly turned into a much longer thread than I expected.
With regard to recommending web resources for mobile bill payment systems, it’s not really an area that I’m very familiar with. Also, it’s been almost 2 years since I did any mobile development myself so I’m getting pretty rusty at this stage. You really would be better off searching the web more generally for such resources – I’m sure that there are much better J2ME forums out there (than this one)
๐
Hi James
with your advice I have getting started my environment:
Eclipse Ganymede, EclipseME and WTK
without seeing the bespoken message furtheron.
I only did the changes within WTK-properties, you described.
Thank you
Christian
Here i can get the setting for sun java wireless toolkit and netbeans. can u give me setting for sun java wireless toolkit and eclipse?
Thanks With Regards
Abhishek
Abhishek,
It has been a long time since I have done any mobile development using Eclipse but at the time, I think I used the EclipseME plugin. Once you have installed this, you should be able to create a new J2ME project (using File, New, Project, J2ME, J2ME Midlet Suite). Then, right-click on the new project and select Properties. From the resulting screen, select J2ME and then Midlet Suite Signing.
Unfortunately, this is all that I can remember but I did find this article which may help you to get the rest of the way along.
The NetBeans mobility pack is a lot better than EclipseME in my opinion so I would not expect this to be as easy in Eclipse as it is in NetBeans.
Hi
Having a tough task handling connection in a separate thread. Actually, I want to retrieve some data from the http connection and use it further in the program. But the main thread runs before the child thread, so am unable to do that. I have already tried wait, notify and join methods, but that’s too not working. please help me out on this. I am using NetBeans IDE 6.1.
Hello, I have done exactly this using NetBeans IDE 6.5 and Sun Wireless Toolkit 2.5.2, and it works! Thanks for the post!
However, I seem to have found a bug for it; if I were to save the whole NetBeans project to copy to another computer, if I don’t do the exact settings for that computer as we;;, it will not work. Upon running the midlet with NetBeans without doing all the settings will cause the program to hang the moment the user chooses Yes or No for the “OK to use Airtime” message, even if the web services connectivity is done on another thread, etc.
Just a heads-up.
Hi Nicolle
Thanks for the reply. I have now shifted the part of the program using the required shared data to the child thread and that’s working fine as of now. But still have a doubt. By settings do u mean that it does not ask for connection? Well in that case I was just wondering that it can then pose problems after deployment on a real device which generally asks for the permission.
thank you for your resolution
Thanks Mernin. I followed your guide and my project runs well now
GRAND Mercy, finally I do not see that stupid error …
hi friends i have problem in netbeans 6.1 when i am run any j2me prog. it will compile success full but i don’t see default phone when run the prog. I am new in j2me & i never use netbean pls help me.my email addr. is deshmane.aniket@gmail.com
my sun java toolkit KToolbar, doesn’t have
* Security Policy: MSA
* Security Domain: manufacturer
options. !!!
any other J2ME emulator exists?
It works. I am using Netbean IDE 6.5. I change the setting all in Netbean, including the preference of Sun Java Wireless Toolkit (right click the project->Category->Platform->Emulator Platform->Manage Emulator->Tools & Extension->Open Preferences->Security
Please I need help on where to insert a code so that I can connect it to a WMA server with an assigned short code, 32142 and a keyword ‘food’…I used Netbeans 6.5, Virtual Midlet to create the apps….pls help!
Hello
running my project in OTA get this error:
** Error installing suite (30): There is insufficient storage to install this suite
please help me.
thanks
Nice one!! solved my problem !! ๐
Thanks dude, really solved my problem, thanks.
My project got the same error when I press ok to use airtime, it doesn’t do anything. Luckly, I solve the problem by your guideness. Thank you so much:)
hi.
i use eclipse and i have some same error.
how i setting this รขโฌลOK to use Airtime” in eclipse
thank
Hi.
How i setting this message in mi device, not on mobile emulator
Thank
Thank you very very much !
thanks a lot..my problem is solved after following these steps
Thanks a lot!! Really helped me get 400 marks this small thing
thanks so much, really help me,…