Showing posts with label Development Problems. Show all posts
Showing posts with label Development Problems. Show all posts

Feb 10, 2009

Netbeans is Getting Better

I am currently writing an article about how to do formatting with Microlog. When doing this I felt that I needed some examples of how the formatting really looks like. Since there are a bunch of example MIDlets in Microlog, it should be as simple as executing them. But that is not the case! As described in an earlier article, it seems that Eclipse is not always fit for fight, it does not manage to start the wireless toolkit.

I tested NetBeans back in 2005 when learning Java ME, although I was an Eclipse fan. For some time I actually used both, I used Eclipse for the development and NetBeans when executing the MIDlets. The reason for this was that EclipseME plug-in was not as good as the NetBeans counterpart. But gradually I started to use Eclipse exclusively. One reason for this was that Eclipse ME matured. When the EclipseME was migrated into Mobile Tools for Java, I have not felt that I was missing NetBeans. But at times when Eclipse fail, I am missing NetBeans. It is a real shame that after all these years, Eclipse still have problems when it comes to Java ME development.

I could spend hours on getting Eclipse to work, while downloading and installing NetBeans should be easy. Said and done! I downloaded NetBeans. Unfortunately my Windows Vista decided to download updates as well, so it took quite some time to download it. I wish I had a faster Internet. Downloading using a 512kbit/s ADSL modem is not the best solution for downloading 211 MB of NetBeans, while at the same time downloading Windows updates.

When writing this article, NetBeans has been installed in the background and everything seems to be working as it should. My first impression is that NetBeans has matured since the last time I used it.

Jan 27, 2009

Maven Problem Solved

The Maven problem that I had the other day has been solved. It was simple a matter of configuration for ProGuard. The problem is described in more detail here. Thanks Karsten for helping me out with this problem.

This brings me to the next topic; there is a new snapshot release of Microlog available. The changes are:
  • Added the ability to print the absolute time with the PatternFormatter. The %d is used for this purpose, to be compatible with Log4j. The date format specifiers are also available; ABSOLUTE, DATE, ISO8601.
  • The ByteArrayOutputStream that is used for creating log data in the RecordStoreAppender was closed, which is not necessary. This has now been changed.
  • Added some useful printouts for the RecordStoreAppender and the RecordStoreLogViewer.
I think that the first item is the most interesting one. The PatternFormatter is almost as capable as its Log4j counterpart. I am looking forward hearing from developers out there, giving feedback about this release.

Please download.

Jan 22, 2009

Maven Problems

I still have not found a solution to the NoClassDefFoundError-problem, but a workaround. The workaround is to execute the code in NetBeans, or another IDE than Eclipse. When doing a release, I encountered yet another problem. This time it was Maven that issued a build error. The output from Maven looks like this:

....
[proguard] Warning: library class cldcunit.runner.ReflectionTestCaseHelper exte
nds or implements program class cldcunit.runner.BaseTestCaseHelper
[proguard] Warning: library class cldcunit.runner.ReflectionTestCaseHelper depe
nds on program class junit.framework.TestMethod
[proguard] Warning: library class cldcunit.runner.ReflectionTestCaseHelper depe
nds on program class junit.framework.TestMethod
[proguard] Warning: library class cldcunit.runner.ReflectionTestCaseHelper depe
nds on program class junit.framework.TestMethod
[proguard] Warning: library class cldcunit.runner.ReflectionTestCaseHelper depe
nds on program class junit.framework.Test
[proguard] Warning: there were 5 instances of library classes depending on prog
ram classes.
[proguard] You must avoid such dependencies, since the program classes
will
[proguard] be processed, while the library classes will remain unchang
ed.
[proguard] Error: Please correct the above warnings first.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Obfuscation failed (result=1)

What does this mean? To me it seems like ProGuard has found a problem with CLDCUnit. So this leaves me with still another issues that delays my release of a new Microlog version. Not good!

Jan 20, 2009

NoClassDefFoundError in Eclipse MTJ

Yesterday I started to implement a new feature in the PatternFormatter for Microlog. A user wanted the ability to print the absolute time. The first implementation was pretty rudimentary, the only available format was the default format used in Log4j's PatternLayout. It worked but today I wanted to improve it. I had planned a snapshot release after that. But I ran into unforeseen troubles. When trying to execute the example MIDlet to try it out, I get the following message in the console window;

java.lang.NoClassDefFoundError: net/sf/microlog/Appender
at com.sun.midp.midlet.MIDletState.createMIDlet(+29)
at com.sun.midp.midlet.Scheduler.schedule(+52)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+80)

Notice that this is not a classic ClassNotFoundException problem. A ClassNotFoundException is always quite easy to fix. You have to check that you have your classpaths in order. This is something that a every Java developer has to learn to fix, otherwise you do not survive as a Java developer for long. But to fix the NoClassDefFoundError is harder. It basically means that your environment has found the class, but there is something fishy with the bytecode. In this case I have no clue. Is this a compiler problem? Is it a problem with the preverifier? I have done Googling on it, but did not find any relevant answers. Is a problem with Eclipse MTJ? Do you have any clue?

So bear with me, there is a new Microlog snapshot release on its way. I will have to fix the above problem before releasing the code. For the impatient developer, the code is available in the Microlog source repository.