July 28th, 2002, 05:07 PM
WAP/WML, Java2ME, logos & ringtones tutorial
I just bought a new mobile phone, a Siemens M50 with support for GPRS and Java2ME. Now this phone proves to be lotsa fun, let me explain:
Java2ME or Java 2 Micro Edition is Java for handheld devices without lots of memory and CPU power (such as mobile phones). Unlike ordinary Java which comes in a single package, ME is modular. That means that there are several smaller modules that can be put together, depending on the power of the device. My phone only has about 256 KB of RAM and a slow CPU which means I can't use all the functionality that can be used on PDAs etc. But that doesn't matter, there is lots of functionality left. Both networking and graphics can be coded, which makes Java2ME on a phone perfect for games & chat and lots of other stuff too.
Oh, the GPRS stuff is a protocol for transfer of data on mobile devices, and is about as fast as an ISDN connection (about 50kbps).
Now for the fun part, how can you get Java to work on a phone? It's quite simple! First you need to code a Java app, so that you have something to load into your phone. To do that you need the Java2SE (standard edition) located here: http://java.sun.com/j2se/1.4/download.html
And the Java 2 Platform Micro Edition Wireless Toolkit located here:
Now, let's create a hello-world applet:
I could have shown you how to do this, but there's a better article for that located here:
Step through this article (tutorial), and look at the files you have created:
You should have one file called HelloSuite.jad, and a file called HelloSuite.jar.
The .jad file is actually a file that tells your mobile device the location of the .jar file, which is the actual application.
Now, how do we get these files into the mobile phone?
To do that, we have to put the files on to a web-page to which we need to surf with the phone's WAP-browser. So we need to create a WML-page (Wireless Markup Language), quite similar to an ordinary HTML-page.
To get web-space you have to sign up with a free web-space provider such as geocities or brinkster.
As I said WML looks like HTML (well actulally more like XML, but that doesn't matter). This is sample code:
Put this piece of code into a file and save it with a .wml-extension (how about default.wml).
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<card id="home" title="home">
This is my WML-page
This you upload onto your web-space.
(There are a few IDEs to create WML out there. I found one provided by Nokia, which is quite usable. Here's the link: http://www.nokia.com/corporate/wap/sdk.html )
Remember the Java files? Let's get back to them. As you can see in the WML code, a reference has been made to the HelloSuite.jad, file (the application description file). Let's take a look at it, it should look something like this:
Pay attention to the third line, it says "MIDlet-Jar-URL: HelloSuite.jar". This explains the location of the .jar-file and would probably work locally on your computer. With files located on the web it doesn't. So we have to change it a little bit to
MIDlet-1: HelloSuite, HelloSuite.png, HelloMIDlet
MIDlet-Vendor: Sun Microsystems
"MIDlet-Jar-URL: http://www.brinkster.com/antionlinem...HelloSuite.jar". Of course the URL depends on the URL of you web-page.
With this line changed, both the HelloSuite.jad and the HelloSuite.jar files must be uploaded to your web-space, same directory as the WML.
Finished! Now start up the phone's browser, insert the url of your wml-page, click on the Hello World-link and you're up and running! (Actually my telephone service provider has some problems with the java support at the moment so it doesn't work on my phone yet.
But this is how it's gonna work in the near future...)
Hmm, in the title it says something about logos and ringtones. What's up with that?? Well, if you inserted a link to a monochrome (2-color) bitmap in the wml page you could download that as a logo (on the Siemens M50 anyway..) Like this:
On the M50, the ringtone format is midi-files with the .mid-extension. These aren't ordinary MIDI files, cause they aren't as complex as many MIDIs are. The M50-MIDIS can be downloaded as well. Just create a link:
Of course both bitmaps and ringtones have to be uploaded to the web-space.
Any questions? Send me a PM!
July 28th, 2002, 08:04 PM
I forgot to mention that this should work with other mobile devices than the Siemens M50. This link shows which: http://www.microjava.com/devices