Oct 30, 2008

New Snapshot Version of Microlog is Available

The Microlog project is as vivid as ever. A lot of things are improving at the moment. It is time for you to try it out.

Important updates:
* CLDC 1.0 compliant, except for the PatternFormatter class. Use the source code version to use Microlog with CLDC 1.0. The binary variant of Microlog is compiled with CLDC 1.1
* MIDP 1.0 compliant.
* Performance improvements.
* Microlog4SPOT code is now merged. It is now possible to use Microlog for Sun SPOT devices.
* The Microlog instrumentation tool is now available. This let you log things like the line number in your code.

Please download and provide us feedback!

Download Microlog snapshot.

Using Amazon S3 in a Different Way

You might have heard about Amazon S3, which stands for Amazon Simple Storage Service. Most people use it for backup. I will tell you a story about how I found a different way to use Amazon S3.

During the summer I felt a deep urge to implement a JDBCAppender for Microlog, like the JDBCAppender found in Log4j. In situations when the on-device logging is insufficient, this would give the developer a chance to log into a database. When searching the Internet I found less than a handful of JDBC implementations for Java ME with CLDC. Most implementation for Java ME devices was CDC compliant. Another problem was that I was to lazy to setup a database. Last but not least, my knowledge of JDBC was a little bit weak since I had not done any JDBC programming for many years. Soo my initial urge was gone like the wind.

But still I felt that there was a need for off-device logging in Microlog. How about Amazon S3? Could it work? Since Amazon S3 could be accessed with REST and/or SOAP, it should be possible to access it from Java ME. The developer resources for Amazon S3 are rather good, and it came as no suprise to find a J2ME Toolkit for Amazon S3. This was perfect for me since it was open source, and is using the Apache License 2.0. This is the same as we use for Microlog.

I coded two appenders for Amazon S3; the S3FileAppender and the S3BufferAppender. The S3FileAppender logs to file. When the file reaches a certain size and/or you log at a specified level, the file is copied to your S3 account. The S3BufferAppender logs to memory instead of a file. This is useful for applications that do not have access to JSR-75, i.e. file access.

But how do you use the S3 logging capabilities of Microlog? It is dead simple. The code look like this:

public S3FileLogMidlet() {
S3FileAppender appender = new S3FileAppender();
// You must set the accessKeyID & secretAccessKey in order for this to work.
// For more information, see your Amazon account.
log.info("Setup of log finished");

log.error("This error message shall trigger file => S3.");

As you can see, you need to insert an access key id and a secret access key. These are obtained from the Amazon AWS pages. If you have ever bought something on Amazon, you already have an account. The only thing that you have to do is to active the AWS service. When you do this you could access these auto-generated codes. Copy and paste them into your code. A word of caution. Be aware that if you somehow loose your mobile device or your account details, you have to change your codes at Amazon AWS. Another solution would be that you enter these codes when starting your MIDlet or that you store them encrypted in a file. But do not say I did not warn you!

The rest of the code is simpe. The appender is added to the logger and the log level is set to DEBUG. The S3FileAppender is by default set to send the file to the S3 server when an ERROR or FATAL message is logged, or when the file is to big. But if you like to send the file only when the file is big this is possible as well. It should be noted that this setup could also be done in a properties file. Please take a look at the Microlog documentation for more details on the different setup options that are available.

When you have compiled and transferred your MIDlet to your device, the logs will be saved on your Amazon account. I use the Jungle Disk application to mount a virtual drive. The logging file will be accessible in your Microlog folder. It is as simple as that. The Jungle Disk application is available for $20 for the version that I use. There are nearly a zillion solutions for Amazon S3, and one of those will fit your purposes.

The benefits of using Amazon S3 for Microlog are many;
  • No need to spend time on setup and maintenance of a database. This will save many $ for you.
  • It is cheap to store the logs at Amazon S3. Even if you log huge amount of Microlog data, it will be very cheap. For example; let's say you store 1 GB of Microlog data. That would cost you $0.20 for the transfer and $ 0.15 if you save it on the server for a month. I believe that under normal circumstances you do not store it for that long.
  • No need for JDBC knowledge. You only need to learn how to use Microlog.
  • Focus on the development.
The only drawback is that the security could be an issue. However as explained, there are workarounds for this problem.

I would like so say some words about the future of S3 logging in Microlog. There is room for improvements. For example, I think it would be useful to log several users log files. As it is now, the S3 appenders are only for a single user. Of course there are other improvements, some of which I am unaware of. Maybe YOU are the one that could help me improve Microlog? Please use the Microlog forums if you have any suggestions.

Install MIDlet on a Motorola C380

Yesterday I had some problems when installing a MIDlet on a Motorola C380. Before doing this I believed that this was something I could do fast and easy. As it turned out, this was not the case. Here is the story.

As in all good cooking programs I had prepared myself. The document "Java ME Developer Guide for Motorola OS" seemed to be the right one. It describe the following ways of downloading a MIDlet to your mobile device;
  1. OTA (Over The Air)
  2. Bluetooth
  3. IrDA
  4. USB Cable
These are all standard ways of downloading a MIDlet. Using OTA for downloading from my laptop would imply to much works, so one of the other ways should be used in this case. Hmmm... Bluetooth should do the trick. Looking through all the menus, but no Bluetooth settings. The specification for the C380 confirmed this. IrDA was not possible either, since my laptop does not have an IrDA port. Lets try to use the USB cable then. Nice that Motorola devices uses a standard USB mini cable. My desktop is full of different brand specific USB cables. I wish that all manufacturers would use standard USB cables, which could simplify things for me.

I used the brute force method for USB connections. Attach the mobile device through USB to your computer, and see if Windows figures out which drivers to install. My Windows Vista installation did not. But I was a little bit surprised when Windows Vista suggested that I should download the Motorola Device Drivers. The link worked and within minutes the device drivers where downloaded.The documentation described a tool called MIDway which could be used for downloading MIDlets to your mobile. This was possible if you could find the "Java App Loader" in the Java menu on your mobile device. It was written that the "Java App Loader" is NOT available on devices that you buy from a standard consumer outlet. You should use the MWay tool found in Motorola MOTODev Studio for Java ME V2 instead. No problem, it was only a "small" download about the size of 112 MB. Estimated download time; 1 h 30 min. This gave me time to be a little bit social with my family. What a bummer :)

I installed the device drivers and Motorola MOTODev Studio. This worked like a charm. I attached my mobile device through USB and now it worked. The device manager showed that a Motorola US modem was installed, as well as some other devices. Now it was time to start MOTODev Studio. Surprise! The MOTODev Studio is Eclipse in disguise. Me like a lot! I found a document about Motorolas MWay Tool v1.0, which was the tool that I was supposed to use. The first step was to find the configuration tool, the second was to activate the "Java App Loader" menu. But wait... the other document stated that this was not available on mobile phone purchased in the consumer market. Appearently it was possible. After restarting the phone the menu was finally available. Connected the phone once more and used the deployment tool to install the MIDlet. Rather easy once you figured it out. But it took quite some time; I started right after the dinner at five and finished about eleven.

I now comes the short version, the version that you could use and save yourself a lot of time.

Some kind of Windows environment. Windows Vista worked for me.

  1. Download the Motorola device drivers
  2. Download the MOTODev Studio.
  3. Optional; if you have a slow Internet connection you could take a long coffee break, watch a movie or something.
The real stuff
  1. Install the device drivers
  2. Install MOTODev Studio.
  3. Connect your Motorola mobile phone. Wait for Windows to do the installation of the drivers.
  4. Start MOTODev studio.
  5. Open the "JavaME" view and select the "Tools" tab.
  6. Select the "Config tool".
  7. Refresh the "Config Tool" and you it should now show some information such as IMEI number etc.
  8. Select the "JAL" option (short for "Java App Loader").
  9. Disconnect your mobile device and restart it.
  10. Choose the "Java Settings" menu found in the settings menu. Select the "Java App Loader". You are now prompted to connect your mobile device. The mobile device should confirm that your JAL link is active.
  11. Select the "Deployment Tool". This is also found under the "Tools" tab.
  12. Select the JAD file that you want to transfer. The JAR file shall be in the same directory.
  13. Select the COM port for your Motorola USB modem. This is found Windows device manager.
  14. Press the "Deploy" icon found in the upper right corner of the "Deployment Tool" view.
  15. Accept the download on your mobile device. Follow the instructions on the mobile device.
You should now be executing your own MIDlet on your mobile device. I tried it on the Motorola C380, but this should be applicable on other Motorola devices as well. Good luck!

I hope that you could save an hour or two when using this guide. Unfortunately you have to download a couple of megabytes, but hopefully you have a faster Internet connection than I have. If you have any problems, you could still use the Motorolas MWay Tool v1.0 document to figure out how to do it.

Oct 24, 2008

Open Source Software Development; Microlog, Microinstall & Voxtr

A couple of years ago I started my first Open Source project; Microlog. This was an attempt to make something similar to Log4j. At that time I was new to Java ME programming. What I wanted was a really simple, but yet powerful logging tool. I started from scratch and within a couple of hours I did have something that I liked. For some reason it just felt right; I wanted to release it as Open Source. Said and done! I also showed it to some of my colleagues and got some feedback. My colleague Darius suggested that I would make the setup of Microlog very simple. Before I knew it, he had contributed with some code for the setup. After that he joined the project. Since I believe in "Release early, release often." I released a couple of small releases rather quickly.

During the years that have gone since then, I have from time to time taken a look at the Microlog project site. The statistics showed that there was a fair amount of downloads. But there was no activity in the forums. Nada, zero, null! :( Since I was not involved in any Java ME development project, there was no natural reason to use Microlog, nor updating the code.

But then there came an e-mail from a developer who wanted to contribute with some code. Wow! Somebody thinks that Microlog has some potential. A couple of days later another person wanted to contribute, and join the project. This was Karsten who now is our Maven specialist in the Microlog team. During the spring and the summer I and the rest of the team has been working very hard to get out the first "real release", i.e. V1.0. We also replaced our old static homepage with an autogenerated site by Maven. During this period we finally got some action in the forums :) Thank you all for the great feedback I have received, this is really motivating me to continue with Microlog.

I have heard many people complain about long URLs that you have to enter to download a MIDlet. Of course you can download the MIDlet to your computer, and then transfer it to your device. Both ways are rather tedious ways of doing the installation of a MIDlet. Therefore I started to think about different ways to distribute MIDlets. My experiments are now available for you to take a look at. Please visit the Microinstall project page site for more information.

I am the co-founder of the Voxtr project. This is a simple voice recorder MIDlet. Since I have a hard time to remember things, it is very practical for me to take "voice notes". No need to find a pen and paper or use that hard-to-use-notepad-application that is bundled on your mobile phone.

That is all for now folks!

Oct 23, 2008

My First Blogpost :)

This is my first ever blogpost in the history of cyberspace. My wife has been nagging me for not blogging, since she has been a frequent blogger for nearly 2 years now. But as they say; better late than never.

To motivate me I have decided what to blog about. Something that really interests me, that inspires me to write regularly about. I have found a couple of things that I plan to blog about. These are (in no particular order):
  • Interesting Open Source Projects, e.g. tools that I use.

  • The Open Source projects that I am involved in. News and stuff.

  • Experiences from my life as an (Open Source) developer.

Of course there will be other subjects to write about, but this is at least the things that I feel I have something to write about. I hope that I will have time to write regularly and that somebody will find my blogging of somewhat interesting.

To be continued...