Geeky Stuff

Computer programming, software reviews etc

How to write Java software for your mobile phone

Posted by on 20 Jul, 2008 in Geeky Stuff | 4 comments

How to write a “Hello World” program using J2ME

So, I’ve just managed to get a Hello World program running on my mobile phone. Thought I would share this as a simple set of steps, since it wasn’t obvious. To figure this out I referred to this guide plus the Sun Wireless Toolkit manual which you will find in {install-dir}/docs/UserGuide-html/index.html after install.

OK, without further ado, here are the steps. This is just one way of doing it!

  1. Install a current Java J2SE Development Kit (such as JDK 6 update 7 (or later) from Sun
  2. Install the Sun Java Wireless Toolkit for CLDC
  3. Run the toolkit ({install-dir}/bin/ktoolbar.exe on Windows – shortcut in Start Menu)
  4. This is the build/compile environment for J2ME apps. Note that bizarrely, it has no text editor, so you need to use your own text editor to create/edit the code, then use this tool to compile/build
  5. Click the “New Project” button
  6. Enter HelloWorld as the Project Name
  7. Enter Hello as the MIDlet Class Name (corresponds to Hello.java, your main java file)
  8. Click OK
  9. Choose your target platform (to keep things simple, use MIDP 1.0 for now)
  10. Make note of the text in the main toolkit window ,this tells you where to put your code and other files. Mine said “Place Java source files in ‘C:\Documents and Settings\Administrator\j2mewtk\2.5.2\apps\HelloWorld\src'”
  11. Using your text editor of choice, open two new text files in that directory, called Hello.java and HelloCanvas.java. The code for these can be found here. Copy and paste the code into each, then save them.
  12. Go back to the tool, and press Build. This compiles your code. Assuming no errors, continue to the next step.
  13. Click Run, this will launch your program in a mobile phone emulator. It should work.
  14. Now, to transfer it to your real phone, you need to generate two files – a .jar file (Java archive) and a .jad file (Java application descriptor). Go to the Project menu, Package submenu, select “Create Package”
  15. You can now navigate to ‘C:\Documents and Settings\Administrator\j2mewtk\2.5.2\apps\HelloWorld\bin\’ and see your generated JAR and JAD files
  16. Now use your phone’s file transfer software to connect to your phone (via Bluetooth, USB etc). I used Nokia NSeries PC Suite from www.nseries.com. Transfer the JAR file and the JAD file.
  17. If your phone does not pick up the app as installable automatically, navigate to the JAD file on your phone and execute it, this will install the app.
  18. You should now find an installed icon for your HelloWorld program in your phone menu (on N95 this is in the Applications sub menu). Click the icon, and voila! Your first mobile phone app!

So, now you can write HelloWorld, in theory you can write any mobile phone application you like – the rest is just programming!!

Read More

ThinkVantage Access Connections – now with extra bugs!

Posted by on 12 Jul, 2008 in Geeky Stuff | 1 comment

Having recently had my IBM Thinkpad T42p reinstalled (the now-standard annual Windows de-bloating surgery), I now find myself with a later version of IBM Lenovo ThinkVantage Access Connections. And it seems this new version is, ahem, shit. I find I really need Access Connections as I switch between multiple wireless networks and wired networks with different security, static/DHCP/DNS settings, etc.

It seems this new version can’t add a new profile without crashing with the not so helpful message “ThinkVantage Access Connections Main GUI Application has encountered a problem and needs to close. We are sorry for the inconvenience”. You’d think that this might have been a good feature to bug test a bit more thoroughly.

I even went to the trouble of installing System Update and through that, got the latest version of Access Connections – still the same version.

It seems I am not alone in encountering this problem, and fortunately, I found a workaround via this link (number 1 link on Google for “access connections crashes” – impressive!) which I thought I would share.

The workaround is to copy another profile then modify it. Far from ideal, but it’ll keep me going for now. Anyone encountered a better solution?

Read More

Gmail misbehaving in Firefox 3 on Leopard

Posted by on 7 Jul, 2008 in Geeky Stuff | 3 comments

How to get back your lost GMail features on Firefox 3 on OS X

Having become more and more aware of how slow and bloated Firefox 2 had become, and having downloaded Firefox 3 on my Windows laptop at work and noticed a definite improvement in load time and CPU usage, I decided to follow suit and install Firefox 3 on my Mac Mini at home which is running OS X Leopard.

It worked fine for a while, then today something strange happened – I clicked my usual GMail link on the toolbar and found myself presented with the HTML only view of GMail and a big flash saying “For a better Google Mail experience use a fully supported browser”.. wtf? Why would GMail not support Firefox 3?

I checked the provided link and confirmed that yes, GMail does support all versions of Firefox after 2.0. I clicked the “Mac” link on that very page and was told by Firefox’s download page that “Mac OS 9 and earlier versions not supported”. Since that page detects your system to give you the appropriate link, this suggests something is reporting my system as pre-OS X, and that is stopping Firefox and GMail from thinking they can support my operating system… How very bizarre.

Read More