Rage Against the Android – Nearly solved! #eclipse #netbeans

After ranting against Android in my previous post I have mainly solved now the untestable situation Android is producing.

Thanks to Robolectric all my tests are finally fast and do not unpredictable hang or similar!

The tests execute nearly as fast as in a normal Maven project – plus additional 2 seconds to bootstrap (dex?). Robolectric was initially made for maven integration on IntelliJ. But it works without Maven and under Eclipse as described here. I didn’t get robolectric working via Maven under Eclipse – and it was overly complex e.g. you’ll need an android maven bridge but when you use a normal Android project and a separate Java projects for the tests then it works surprisingly well for Eclipse.

Things you should keep in mind for Eclipse:

  • Eclipse and Robolectric description here
  • In both projects put local.properties with sdk.dir=/path/to/android-sdk
  • Android dependencies should come last for the test project as well as in the pom.xml for the maven integration (see below)

But now even better: when you are doing your setup via Maven you can use NetBeans! Without any plugin – so even in the latest NetBeans version. But how is the setup done for Maven? Read this! After this you only need to open the project with NetBeans (or IntelliJ).

Things you should keep in mind for Maven and NetBeans:

  • Use Maven >= 3.0.3
  • Again: put the android dependencies last!
  • Specify the sdk path via bashrc, pom.xml or put it into your settings.xml ! Sometimes this was not sufficient in NetBeans – then I used ANDROID_HOME=xy in my actions
  • Make sure “compile on save” is disabled for tests too, as I got sometimes strange exceptions
  • deployment to device can be done to:
    mvn -DskipTests=true clean install      # produce apk in target or use -Dandroid.file=myApp.apk in the next step
    mvn -Dandroid.device=usb android:deploy # use it
    mvn android:run
  • If you don’t have a the Android plugin for NetBeans just use ‘adb logcat | grep something’ for your UI to the logs

Thats it. Back to hacking and Android TDD!


Debugging PHP with NetBeans

How easy is it to make debugging working for PHP code? With NetBeans no problem! Only 5 easy steps!

  1. Download NetBeans 6.9 (although I am using the old 6.8)
  2. If you are on ubuntu installing xdebug is a one liner:
    sudo pecl install xdebug

    write down the path to xdebug for me it is

  3. add the following to your php.ini (on my system at /etc/php5/apache2/php.ini):
  4. apache2ctl restart.
  5. Set a breakpoint via clicking on the line number. Then right click the project->Debug (Select ‘Server Side PHP’). Now you should see sth. like this:

    Check the ubuntu thread, the xdebug site and the netbeans site if you have still problems.

Now you should be able to execute your code step by step with F8, continue with F5 and e.g view the content of variables: select parts of the code and see the result:

And a lot more feature like inspecting deep objects with the ‘Variables window’:

This is not as mature as the Java Debugger but a better then printing echo statements 😉

Where is UML for NetBeans 6.8?

Flattr this to let me do an update for NetBeans 7.0!


Recently I wanted the good and fancy UML editor for NetBeans 6.8 to display the class diagram of our twitter search jetwick, but I couldn’t find it in the update center.

The  solution seems is simple. I clicked here and got the zip called netbeans-6.8-200912091457-ml-uml.zip which needs to be extracted into your NetBeans installation. After this I was able to create an UML project from the project menu:

I created a project to reverse-engineer my java project where even maven (jar or war) was possible. Look here:

But at the time of NetBeans 6.5 the packages were filled with content! Now they are empty and no class diagrams can be easily generated from source code 😦

The import of the java files seems to work, because if I right click the project I could create a model report with all my classes and its dependencies.

Do you know my mistake? I just wanted to create a class diagramm from my project.

Update: There seems to be no solution for NetBeans 6.8. See StackOverflow.

Update2: No, wait. Read this.

CRUD with Wicket + Guice + Db4o / NeoDatis

The journey began with a search for a database for my desktop application TimeFinder. It turned out that there are at least 3 candidates if I would choose a simple and only one tier architecture:

  1. GORM
  2. NeoDatis
  3. Db4o

One tier applications would only make sense for some special uses cases like in my case for high schools with one timetable admin. But it would be a lot better if I could use sth. like remote GORM, remote object persistence or even an ajaxified web application. Yes. Why not? What, if I rewrite the UI from scratch and move from ‘Swing Desktop’ to web? But then again: which web framework and which persistent architecture?

A lot of people would recommend Grails (myself included) if I need a simple CRUD web framework, but for me Grails is a bit heavy weight (~ 20 MB) and I will have to live with at least 6 languages: GSP, JS, HTML, ‘Spring-XML’, Java and Groovy. I will need Java at least for the performance critical part: the timetabling algorithm.

Okay. Then, why not GWT or Eclipse RAP? GWT has Javascript compilation, which I am not a big fan of and Eclipse RAP requires pure Eclipse development, I guess. So what else? There are a lot of Java web frameworks (with Ajax) as I discovered earlier. My choice now was simple: Wicket, which is Swing for the web. But what if you don’t like Swing? Then you will love the ‘Swing for the web’ 😉 !

Wicket Features

From what I learned in the last days and from blog posts; Wicket is outstanding in the following areas:

  • Separation of UI and code. You only have
    • pure HTML no new syntax required ala JSP, JSF, GSP, velocity, … the latter one was the reason for not choosing click. No Javascript hassle … if there are some, then I trust the wicket community to fix them in wicket itself
    • and pure Java. This is very good if you’ll someday refactor your code. And you’ll.
  • You can create your own components easy and fast. You can even create ajax components without xml and js… only Java.
  • A strong community (even a German book)
  • No route file necessary. (This can be a disaster for manually managed JSF apps)

Okay. And the persistent layer? That was the reason for this journey … hmmh, there are already several different persistent ‘technics’ for Wicket available:

Hmmh, but I only need a very simple persistent layer. No complex queries etc. As I mentioned earlier I can even live with xml (for datastorage). I decided to look into db4o again (used it in gstpl which is the antecessor of TimeFinder) and into the more commercial friendly (LGPL) object oriented database NeoDatis. The latter one has an option to export to xml and import the same, this would be great so that I don’t have to think about database migrations (some refactorings will be applied automatically. see 1.10 in the PDF docs). Migration in db4o should be easy too.

While I was thinking about that, I asked on the Apache Wicket mailing list for such simple persistent solution. Jeremy Thomerson pointed out that there are even some maven archetypes at jweekend which generates a simple Wicket app with persistence for me. I chose the Wicket+Guice+JPA template and updated this to use Guice 2.0 and the latest warp-persist according to this post. After that I needed to make db4o or NeoDatis working. For the latter one I needed warp-persist-neodatis and for the first one I only needed some minor changes, but they took a bit longer.


For those who want to see the results, here are the 2 independent maven projects (Apache License 2.0) within my subversion repository (revision 781):

To try the examples just type ‘mvn install’ and run ‘mvn jetty:run’. The resulting war file is amazing small: under 6 MB!

Now point your firefox or opera to http://localhost:8080/timefinderwicket/

And here is the screenshot:

As you can see the localized warning messages are already provided and shown instead of “Please enter a value into the field ‘location'”.

To work with wicket is a great experience! In another project it took me about 10 minutes to convert a normal submit into an ajax one which updates only selected components. And then, in the NeoDatis project I initiallly developed my EventDataView against a completely different data item and moved the source nearly unchanged to the db4o project with the Event class! That is nice component oriented development. Okay, I did copy and paste rather then creating a maven submodule for the pageable list, but that wouldn’t be that difficult with wicket. Then as a third example I overwrote the navigation panel, which was easy too: Now instead of

<< < 1 2 ... > >>

it will be shown

First Prev 1 2 ... Next Last.

without touching the UI. You can even provide ‘properties’ files to apply easy I18n.

Coming Home

Wicket is like coming home ‘to desktop’ after some years of web development, especially in the UI layer. And guice perfectly meets my dependency injection requirements: pure Java.

To get all things right I had to tweek the initial example of jweekend a lot, but all necessary changes were logically and does not smell like a hack. As a first step I updated the versions of the artifacts and then I added a DataView from the repeater examples. The developed CRUD example is now built with dependency injection instead of the original locator pattern (ala DatabaseLocator.getDb()):

Provider<ObjectContainer> oc;

Then the update mechanism and some other exception must be solved, but you only need to check out the sources and see what is possible!

As a side note

please keep in mind that there is a NetBeans Plugin for Wicket 1.4.x and an IntelliJ plugin for the same. For all NetBeans guys which are interested in ‘deploy on save’ feature you only need to enable ‘Compile on Save’ and then you can change code or HTML in Wicket, if you are running the application via jetty:run (jetty configuration is already done in the pom). Currently this works only with db4o as a standalone server. To my knowledge this way of UI prototyping can be even faster than with Grails, where it could take some seconds to be recompiled.


Dive into the world of Wicket right now!

Java Application Frameworks (not only client side …)

In an old post I listed all Java libraries,where only two application frameworks were listed.

Today it is time to list some client side Java application frameworks, because I discovered some new ones while reading the W-JAX announcement. Some of the listed frameworks will make developing application with DB easier. And some of them are real 3 tier architectured frameworks. Some of them even allow you to develop RIA’s and web frameworks at the same time.

Here is now the list of open source Java application frameworks especially for the desktop. Feel free to add some more (via comment):

  1. NetBeans RC Platform, my IDE is build on this 😉
  2. Eclipse RC Platform, has an interesting ‘subproject’ called Riena
  3. Spring RC, at the moment my favourite used in TimeFinder
  4. AppFramework which won’t be in JDK 7, but has a lot of derivatives
    1. Swing application framework fork
    2. Guice Utilities & Tools Set
    3. Better Swing AppFramework
    4. with OSGi
  5. JVx, looks very nice! Makes fast development of Swing applications possible (with db support)
  6. OpenXDev a framework which could be used as a base for your next Swing project
  7. Genuine is a client framework for Java Swing applications for which it provides basic infrastructure
  8. Genesis with Swing and SWT binding; Easy, transparent remoting; etc
  9. GWT (although only intented for javascript widgets it could theoretically being used as a rich client running in the jvm)
  10. OpenSwing Framework is an open-source suite of advanced graphics components based on Swing toolkit
  11. Leonardi Framework
  12. Jspresso is a framework for building rich internet applications
  13. Viewa framework
  14. XUI is a Java and XML RIA platform
  15. Swing + XUL = SwiXAT looks interesting but dead, the same for the next:
  16. Swing + XML = SwiXml a small GUI generating engine.
  17. buoy built on top of Swing. Xml serialization of UI possible
  18. But why xml if you have groovy: Griffon 😉
    Now, a nice approach would be to send/receive groovy code and build the clients’ GUI on fly… this would be like replacing the browser+html+javascript system with rock solid JVM+Groovy 😉
    Another Comment from AndresAn addtional tidbit about Griffon, it can be seen as a polyglot programming desktop/RIA framework as it supports 5 JVM languages at the moment: Java, Groovy, Scala, Clojure and JavaFX. It also lets you embed JavaFX components on Swing containers.
  19. JMatter is a software framework for constructing workgroup business applications based on the Naked Objects Architectural Pattern.
  20. Metawidget is a ‘User Interface widget’ that populates itself, at runtime, with UI components to match the properties of your business objects.
  21. Pivot a platform for building rich internet applications in Java

Especially JVx with a webstart demo looks very promising! It even feels better and faster than an ordinary flash application!


  1. Aviantes-Business-Application-Framework
  2. Jide Desktop Application Framework
  3. Jazz

I listed only frameworks which help developers to easier build client side desktop application and only if they run in the JVM. So frameworks where the client is browser-based (aka web frameworks) are not listed here.

For a good list of J2EE frameworks go to java-source.net or to wikipedia. (Or here, or there, or even here)

Update: For additional comments look at dzone

Import/Export Code Formatting Settings from NetBeans

In short: To share settings (e.g. code formatting) from NetBeans with Eclipse a little bit work has to be done.

For NetBeans you have the following possibilities

  • Either directly use the file
  • Use the eclipse importer. Now you can use the project within NetBeans and sync etc.
  • Or  you could load the settings (e.g. the settings from previously imported eclipse project) via “right-clicking the project”->Properties->Formatting->Use project specific options->Load from other projectper-project-settings
  • Other possibilities? Let me know!

I had an Intelligent IDEA: Two days without NetBeans …

Yesterday and the day before I tried the unbelievable: I used not my favourite IDE NetBeans (6.7) – I used IntelliJ Idea (8.1). Five months ago I got the free license from Jetbrains for my open source timetabling application called TimeFinder, but I hadn’t the time to try it out. And why should I?

People from Pannous say Idea is the best IDE and everywhere else I could read about fantastic features. But read this to get an answer from Jetbrains and read the text below to get subjective impressions on the subject “IntelliJ IDEA as a NetBeans user”.

Every start is stony, so I tried to configure the layout and some more things to my needs. Then Idea looked good although not like a native application (which is great under gnome ;-)) The most important step I did too late, but you should do it as a first step: print the keyboard shortcut reference and highlight your important one. Another good resource for NetBeans user using Idea is the FAQ from Jetbrains, where I discovered that you can even use NetBeans shortcuts as well… and you don’t have to worry about using 2 IDEs at the same time:
“The NetBeans .nbproject directory and build.xml remain untouched, so you can continue using IntelliJ IDEA along with NetBeans.”

After this personal-warm-up I opened the root module of the maven project from TimeFinder and this worked simply by opening the project’s pom.xml. To run it a minor set up was necessary: the JDK_HOME and the M2_HOME (/usr/share/maven2 for ubuntu) needed some values. But after this I could run a file with a main method in it via CTRL+SHIFT+F10. The following points I made for myself along the days:

  • To import a J2SE project Idea is pretty slick: it searches even for existing jar files and allows you to specify a dependency.
  • Running single tests is possible with Idea.
  • You cannot select a local variable and the usages will be highlighted
    From comments: “Settings | Editor | Highlight usages of element at caret”
  • There is only one “Search” possible in Idea (Not several search tabs …)
    From comments: the “Find Usages” dialog has an option “Open in new tab”
  • The built-in on-the-fly static code analysis is be a bit more fined grained in Idea

The points are based on my own experience with 8.1.3, please search on the web to proof me wrong. And please think before you post some constructive comments and facts 😉

My personal FAQ which I created to ask YOU:

  • Is there really no explicit handling for unit test folders?
    Answered. See comments
  • Does it really takes so long for project loading?
    See comments
  • Why is there no simple create jar from J2SE project?
    See comments
  • How can I move the tabs around?
    I would like to have my todo file always on the very left … regardless of when I opened it.
    See comments
  • Why is there no “test” button like there are “run” and “debug” buttons?
    See comments
  • Why I have to set the working directory for a maven configuration?
  • Is it possible to have two projects opened at the same time in the same frame?
    The FAQ answers this with:
    Each global window with IntelliJ IDEA instance represents a single project. Is this true?
  • Could you get rid of the three project files for Idea?
    Yes, there is a new directory-based project format available in IDEA and can be used instead of the traditional .ipr project format
  • Why is there a separate project called RubyMine? Is this the same like the ruby plugin?
    See comments
  • And how to import existing rails applications?
    From comments: use “New Project”, select Ruby module type and select the existing app directory as the location. Then select Ruby on Rails and “Use existing”.
  • Are there features from NetBeans that are not present in IntelliJ IDEA?
    With a honest answer in the FAQ:
    IntelliJ IDEA does not currently provide an RCP platform. Profiler is not available out of the box, although it can be installed as a plug-in. JavaFX support is still basic in IntelliJ IDEA and C/C++ is not supported. There are fewer visual designers in IntelliJ IDEA than in NetBeans, although visual approach seems to be less important for professional developers due to various limitations of visual designers. Other features should be on par or have better support in IntelliJ IDEA according to our current knowledge.
  • Are there features from IDEA that are not present in NetBeans?
    Please look in the FAQ for reasons.
  • Where is Matisse?
    You can read more about the designer used in Idea here.
  • BTW: Since when is Roman Strobl working for Jetbrains?But how can I run all tests in the test folder?

To come to a final conclusion I would like to know the answers on all these questions … although …

I think every IDE like eclipse, netbeans or idea is great as long as the developers are efficient with it (and knows how to configure/setup/work with). I think it is not wise for a company to force one IDE at work, because not all developer have the same knowledge or requirements. One user likes to configure everything and to work without the mouse, the other developer just want to start coding…

So, it is not really important if NetBeans is the best IDE or Idea or whatever – just use maven or ant projects (or some newer things) and every developer can get happy with its own favourite IDE.he “Find Usages” dialog has an option “Open in new tab”use “New Project”, select Ruby module type and select the existing app directory as the location. Everything will be configured automatically for you.

Help To Stabilize NetBeans 6.8

From the website:

“Is it easy for you to play with a software and find a defect? If you are an experienced NetBeans user and if you find few hours per week from September through November you can join other community volunteers in NetCAT 6.8 program. Get your favorite NetBeans bug fixed and find new friends.”