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!

Rage Against the Android #eclipse

Developing Android applications on Linux with Eclipse sometimes can get really ugly. Sadly neither NetBeans which has a really nice Android plugin, but cannot execute a single test nor IDEA can rescue me or make me switching 😦 but probably they wouldn’t rescue me due to problems of Android development kit itself – I’m not sure.

Update: Have a look at my solution

So, I’ve collected some of the most common problems I encountered while developing an Android app and how to ‘solve’ them:

  • Problem: Eclipse says ‘Your project contains error(s), please fix it before running it.’ and you cannot find a problem.
    1. Open the problem tab. fix the described errors.
    2. Make sure that you included all necessary jars in your build path
    3. Sometimes even this can help: rm ~/.android/debug.keystore
  • Problem: you cannot debug your application
    1. check if debuggable = true in application tag of manifest xml
    2. if that does not help or if you are getting “Can’t bind to local 8601 for debugger” in the Console tab then read this and make sure you use only the line       localhost
    in your hosts file. if not, change the file and restart adb (see below)
  • Problem: Error “AdbCommandRejectedException: device not found”
    Solution: restart adb (see below)
  • Problem: you cannot select one test case to execute
    Solution: run the whole (android) juni test or a package and then select via right click to debug one single test

If nothing seems to help then try one or all of the following steps:
1. restart device
2. restart eclipse
3. restart adb: sudo adb kill-server; sudo adb start-server

Please add your problems and solutions in the comments 😉

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

Plugable Spring RC? (OSGi with Spring Rich Client)

My last post was about pure Swing, which could be easily OSGified. OSGi technologie can be e.g. used to hotdeploy or undeploy jar files to your application server (at the moment only Spring’s server is suggested) or simply to update your Swing application at runtime or write plugins for them. I don’t know for sure, but it seems to me that Eclipse is the most prominent user of OSGi (equinox is one implementation of the specification…) as desktop application, although NetBeans can now use OSGi bundles.

(BTW: do you know a funny myth where the small “i” from OSGi could come from? No? Read the comments here!)

In the last post I show you several swing applications, which were successfully OSGified, today I would like to list Swing- or Eclipse-based applications which use Spring Dynamic Modules:

Then today, in contrast to my last post, I would like to show you an identical solution for the Spring Rich Client project.

Why should I use another framework on the top of OSGi? This is simple: Spring DM provides several nice features, like no dependency on the OSGi implementation (felix, equinox, knopflerfish) and even no one on OSGi at all. Everything (and think) is a bean, like always! But why Spring DM? Why not Declarative Services from OSGi itself or Apache iPOJO? This is simple: I don’t know the others and Spring Rich Client cries for the Spring solution 😉

But to make this short story very short: after struggling the last two days to get Spring Dynamic Modules integrated with Spring Rich Client I gave it up and tried the pure OSGi solution – and – it works. It might be an ugly solution for all those of you who like dependency injection, but this can be optimized later. Today this might be the first plugin for Spring Rich Client – ever:


The button “say hello” with its JOptionPane message was installed through the dynamically loaded plugin. The source code is nearly identical to the one in my previous post. Just add the Spring RC startup before you grab the menu from the application to create a MenuTracker, which calls the MenuService(=plugin):

public void start(BundleContext context) throws Exception {
 menuTracker = new MenuTracker(context, Application.instance().getActiveWindow().getControl().getJMenuBar().getMenu(1));

The source is available from my TimeFinder project via:

svn checkout -r 595 https://timefinder.svn.sourceforge.net/svnroot/timefinder/trunk timefinder

Be sure to start the application from de.timefinder.core.osgi.Activator (main method!).

I hope this post inspired someone to be the first one with Spring DM + Spring RC marriage … or sb. suggests working examples how Spring DM could be started from command line or from NetBeans.

Hints for Mavenization of Java Web Applications

I discovered that it is not that easy to transform a web application from a native eclipse/netbeans project to a maven project.

Here are some hints which can make your life easier:

  1. To create the project structure for the web application use this command:
    mvn archetype:create -DgroupId=de.mycompany.app123 -DartifactId=mywebapp -DarchetypeArtifactId=maven-archetype-webapp
    Be sure you replaced the 2.3 header with
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    this was helpful for fixing this issue:
    "The selected Java EE version does not support selected JavaServer Faces version" + restart netbeans!
  2. To use jdk 1.6 do

    Maybe for you it is necessary to use tomcat 5.5 for myfaces 1.1. Therefor you probably have to change the <source> element to 1.5 … Here you can determine the class format version
  3. use
    for the missing dependency in hibernate org.hibernate:hibernate:jar:3.2.1.ga: javax.transaction:jta:jar:1.0.1B
  4. All libraries which you need at compile time but not on the server (like the following) should get an scope=provided
  5. All libraries which you need for your tests (e.g. junit or hsqldb) should get an scope=test
  6. If your tests are temporarly broken or if you want to speed up testing do:
    (See this post for a better solution.)
  7. To invoke the tomcat plugin (‘mvn tomcat:run’) the following code can be necessary
    This plugin uses tomcat5.5, to use tomcat 6.0 compile it for yourself or run the project from within your IDE with maven plugins.
  8. To invoke the jetty plugin (‘mvn jetty:run’) the following code can be necessary
  9. You get an exception like the following in NetBeans??
    [ERROR]Runtime Exception thrown during execution

    Solution 1 -> use external maven (command line)
    Solution 2 -> try to recompile the project from command line
    Solution 3 -> try to recompile another maven project + restart the IDE (works only sometimes)

  10. if you want to mavenize jar files -you can use this
  11. to set up you own maven repository you can try this tutorial
  12. And last but not least: Be Warned!

Read the following hints if you are an IDE-guy

  • Install the NetBeans plugin. Installation of this is easy -> Options->Plugins->Install Maven Plugin. To use this plugin simply open the pom.xml directly.
  • Installation of the EclipsePlugin:
    • install tomcat 6.0 server (>6.0.16)
    • you will need WTP >2.0.2
    • add http://m2eclipse.sonatype.org/update/ to your update pages; I didn’t tried q4e
    • and install m2eclipse
    • select the necessary packages (scm and mylyn didn’t worked for me …)
    • if not already done add a jdk as default virtual machine to eclipse
    • specify the same java exe in the eclipse.ini file:
      C:\Program Files\Java\jdk1.6.0_07\jre\bin\javaw.exe
    • restart eclipse

Some people want to avoid the stuff related to IDEs – they can!

  • Install maven2
    • Under debian you can simply ‘apt-get install maven’.
    • Under windows you have to add the bin folder of maven to the PATH variable.
  • Type the following in the root directory
    1. mvn install
    2. mvn tomcat:run
  • Then go to http://localhost:8080/yourapp/ with you favorite firefox 😉

Now, my two questions to the readers are:

  • How can change the default tomcat-users.xml under target/tomcat? (for the command ‘mvn tomcat:run’)
    If I would require the user to login (security-constraints in the web.xml) I cannot login …
  • How can I use a master (or parent) module with web applications? I need an example! I already have one for a desktop application.

Encoding issues. Solutions for linux and within Java apps.

Puh, encoding! Did you ever have trouble with it? No? You must be a lucky guy!

Even none-developers should have problems with it e.g. if they use different operating systems.

What is encoding? And what’s so difficult with the encoding?

First encoding (better: character encoding) defines how characters have to be saved to be displayed correctly in your editor or look at the wikipedia definition to be correct. Update: here is a nice introduction.

For example if your editor only reads ASCII files all is very simple: it will use every 8 bits of the bitstream to get a number. Then it will interpret this number according to the ASCII-table. So, if it finds a 97 (this is 0x61 in hexadecimal) it prints ‘a’.

(BTW: look at this nice ASCII-art.)

But what if the encoding is another one? Or if even the bitstream should be splitted into 16-bits-packages instead of 8-bits-packages?

Then the user won’t see the correct information!

Second: On linux everything is in UTF-8. Windows uses CP 1252. and so on. Not good!

(With everything I means: clipboard, default file encoding, …)

How can you (as an end user) handle this under linux?

There are at least 4 programs that helps you with encoding issues under linux:

  • There are command line utilities in linux where you can determine automatically the encoding of a file: enconv and enca or open the file in firefox and go to View -> Encoding and view the detected encoding!
  • To change the encoding of file-content the editor kate is really great:
    Go to extras -> encoding and try it out.
  • Change the encoding of the content of several files which come from windows and you want to have them in linux then use recode:
    recode CP1252..UTF-8 *
    recode ISO-8859-1..UTF-8 *

    do the following to backup the original files:

    mkdir test && cp * test/ && cd test
  • Another command line utility is iconv (or here)
  • Change the encoding of the filenames with convmv (files e.g. from windows).
    To preview the change do:

    convmv -f cp1252 -t utf8 *

    To do the change:

    convmv --notest -f cp1252 -t utf8 *

How does Java handle encoding?

Java is platform independent one should think, but it isn’t regarding to the encoding.

For example: if you read a file correctly under linux, this could fail if you don’t specify the encoding explicitly, because it assumes it is utf8 and under windows it will use another default!

To override the default use: ‘java -Dfile,encoding=UTF-8’ or be explicit with the encoding! E.g read characters from a stream with the following lines:

BufferedInputStream iStream = new BufferedInputStream(urlConn.getInputStream());
InputStreamReader reader = new InputStreamReader(iStream, "UTF-8");

Another issue could be Java source files. They can have different encoding. You should use UTF8, because this is the encoding Java uses for its Strings.

In NetBeans 6.1 change it in the project properties (right-click on the project->properties)->Source->Encoding

In Eclipse 3.4 go to the preferences (menu Window) -> General ->Workspace->text file encoding

But this is only useful for desktop applications like my open source timetabler. But what if you do web development? All fine there? No not really. Then you might get additional problems with url encoding or xml parsing. For the latter one the fix is simple:

  • XML: <?xml version=”1.0″ encoding=”UTF-8″?>

But for url encoding the following does not really work:

  • JSP: <%@page contentType=”text/html; charset=UTF-8″ language=”java”%>

Apropos JSP – I had an encoding issue with the request. Try the following:

<% out.print(“RESPONSE character encoding=” + response.getCharacterEncoding() + ” “);
out.print(“REQUEST character encoding=” + request.getCharacterEncoding() + ” “);
out.print(“JVM encoding ” + System.getProperty(“file.encoding”) + ” “);

//EVEN here we get request parameter in wrong encoding

You will see that the request is null if I am not wrong. And then Java will use utf8? NO!

It will use ISO-8859-1! Why? It is written in the standard!

A simple request.setCharacterEncoding(“UTF-8”); would help if all browsers would send its request according to the header of the jsp. But this isn’t actually working for my use case. So I grabbed the strings from the request via this helper method:

private String toUTF8(String str) {
        try {
            return new String(str.getBytes("8859_1"), "UTF8");
        } catch (UnsupportedEncodingException ex) {
            return str;

Update 1: Read this or this to get a better workaround with a javax.servlet.Filter, webserver parameters and jsp configs.

Update 2: The following snippets could be useful if you are using maven and want to make the application UTF-8 aware:



Update 3:

A good side with a lookup table for Unicode characters



I invite you to post all your experiences with encoding problems in java.
E.g. how to force jboss or jetty to use utf8?

Real Time Editing with Eclipse and NetBeans

Do you know what real time editing is?

No, then look at this fantastic video to see this feature in Eclipse.

Or browse through this tutorial. It is really great.

I love NetBeans. So is there something similar for NetBeans? Yes! There is a collaboration plugin, but I tried it for myself and, sorry, it is really bad.

Update: You need a private server and then it should work

Here you have my bug list:

  • if I remove a contact, it will be listed the next login
  • if a disconnection happens then one can choose ‘don’t show this dialog again’. This does not work

So the previous bugs are not bad. But then when I tried it with a developer (of timefinder.de) it is only useable for a normal chat, because:

  • the editor will not being updated (after some minutes)!??
  • if you remotely execute the program you will do it several times, because you won’t get a feedback, wether starting was successful. thats awful.

But please proof me wrong and contact me via

  • Install the Developer Collaboration plugin in NetBeans 6.1 via: MenuBar->Tools->Plugins
  • Follow this collab-instructions. It is important to use the server: share.java.net and then add timefinder or peatar to your conversations.

Java Web Frameworks Survey


Recently I began to play with Eclipse and web frameworks, because I will use Eclipse at work and there I will program with JSP. Another reason for this web-framework-survey is that I need a web front-end for my open source project Jetwick.
I love Swing so I looked how easy it is to program something useful with up-to-date web frameworks in comparison to Swing. For NetBeans support of several web frameworks (gwt, wicket, …) please look here.

The example I implemented in all frameworks is very minimalistic, but includes three basic components. The example offers a ‘Button’ to perform some gnuplot statements, which will be grabbed from a ‘TextArea’. On the server the statements will be performed (through gnuplot) and the user gets back the calculated image. E.g. if you type ‘plot sin(x)’ and click the button you will get the appropriated graph as an image within the web page.

I used the following statements for gnuplot and you can increase the isosamples to 100 to see what will happen if the respond of the server takes too long:

set xrange[-3:7]
set yrange[1:5]
set isosamples 50
set hidden3d
splot exp(-0.2*x)*cos(x*y)*sin(y)

Just copy and paste this into the appropriate ‘TextArea’ of the application.

Why I chose gnuplot?

  • it is free and available under linux and windows.
  • it looks nice
  • integration into LaTeX is best (good for scientists)

I used my simple class (see WebGnuplot package) to get the image from gnuplot, although there is a nice JNIBinding for gnuplot available at sourceforge.

Web Frameworks

I only chose the ‘most interesting’ frameworks, which are open source. The decision which one is interesting and which not was random. And I excluded frameworks where I need to program directly with Javascript. If you know other projects, where I can program in pure Java, then please let me know! Or ask me if you have suggestions or questions about the implementations.

Here is the list and how to access them in the example:

Click on the links to go directly to the web page of the product. Through this web framework comparison I have the feeling that there are some categories of frameworks:

  • Swing like approach: Echo, Thinwire and WingS
  • ‘Integrate components’ into HTML: Wicket and Click
  • ‘integrate scripts’ into HTML: JSP, ZK (maybe better: ‘action based’?)
  • compile Java to Javascript: GWT

Please help me here to use existent categories. Or this one and this.

Further Work

I will add some more frameworks in a later post. E.g. Struts, Stripes, MyFaces, Seam, SpringMVC, IT-Mill Toolkit and jZeno? Please make some suggestions here.

For some more Java web frameworks look on my own list, on java-source.net or on therightsoft.com. Or take a look at this nice comparison. .



As the first step I created a Swing UI within 3 minutes – I will compare this later with the web frameworks.

Here is a screenshot of the result (It is not nice, but it was fast … and well, late):

Additional Information:

  • User Libraries: ‘WebGnuplot’ (See the resources section)

Click Framework

Click is compareable to wicket, but it is slightly easier I think. It is a lot easier than JSP, because you don’t need getters and setters (i.e. an extra bean) – just the variable (e.g. form) which will be mapped to the HTML correspondent ($form), which is an identifier of the used scripting language (velocity). This means you haven’t to know the HTML specific components like in wicket, although it is a plus if you know them. It took me about one hour to get it running. I didn’t try the adapted Eclipse (clickIDE), but with this IDE you should easily edit the HTML file’s e.g. velocity support for the editor.

Here you can see the result:

Additional Information:

  • It seems to me that click integrates very good with Cayenne. Cayenne is an object relational mapper (ORM) and a nice (easy!) alternative to e.g. Hibernate.
  • I needed an extra servlet, which returns the image as an OutputStream.
  • A nice page returns if an error occurs with a lot of details and the full stack trace.
  • User Libraries: ‘Click’, ‘WebGnuplot’ and ‘Servlet API’ (See the resources section)
  • License: APL 2.0


Echo was the first web framework I tried. It was very easy and fast to get it working (less than 30 minutes). The only big difference to Swing was the AwtImageReference class, which I had to use for displaying in the label. It is nice that a message window pops up (‘Please Wait…’), if the respond of the server takes too long.

Here you see the result:

Echo2 Results

Additional Information:

  • User Libraries: ‘Echo’ and ‘WebGnuplot’ (See the resources section)
  • License: MPL

Google Web Toolkit

The Google Web Toolkit works different compared to all other frameworks. So it took me a lot of time (5 and more hours) to get it working and understand what to do. I will explain the procedure now.

  • You will have to compile the Java sources. Put the server side one into a sub-directory ‘server’ and the client side one into ‘client’. To compile the source you have to call ‘GWT-application-compile’ for this example. For the client side the compilation step generates Javascript sources from Java – to be executed on the clients webbrowser. And for the server side the Java code will be compiled and GWT generates e.g. the web.xml and some more files.
  • Then you can run your application in a ‘normal’ browser, if you deploy the application to the server. But there is another mode, they called it ‘host mode’, where client AND server code run on the virtual machine (jvm). Then you can test your application directly within Java, which is very useful for debugging I think.
  • For the interaction between client and server the GWT uses Java’s remote procedure calls (RPC). I will use it in the example, because the Image class does not support bytes or BufferedImage as input. So I send the gnuplot statements to the server (via RPC) and then the client reads the image from a separate ImageServlet (which knows the statements). This routine is a little bit complicate, but otherwise I wouldn’t use RPC and cannot show you how it works 😉

Another concept of GWT is that you have to define ‘slots’ within the HTML files. From Java code you can access those slots via:

VerticalPanel vp = new VerticalPanel();


RootPanel rp = RootPanel.get("appSlot");

if(rp != null) {  rp.add(vp); }

This makes it easy to integrate GWT in your current development. E.g. to enhance static content with some AJAX.

I got the following result:

Additional Information:

  • User Libraries: ‘GWT’ and ‘WebGnuplot’ (See the resources section)
  • GWT is a client centric framework
  • It is possible to let GWT create you an Eclipse project if you want an easy access to compilation etc. (I didn’t try this…).
  • There is a NetBeans plugin, which makes development very easy (without that I wouldn’t have figured out where my configuration mistake was…).
  • You will have to replace the linux specific jar by the jar of your OS. But I don’t know how to generate a compile and a shell script for this specific project. Normally you would run the ‘applicationCreator’.
  • I needed an extra servlet, which returns the image as OutputStream
  • License: APL 2.0


JSP was (and is?) the standard technology for a lot of companies to create web projects. It works similar to ASP.

To get started it takes me only approx. one hour.

Here you can see the result:

Additional Information:

  • User Libraries: ‘WebGnuplot’ and ‘Servlet API’ (See the resources section)
  • I needed an extra servlet, which returns the image as an OutputStream
  • License: APL 1.1


Thinwire’s last published version is relative old – maybe the authors skipped the development.

Update: This is not true. Look here and here.

I think it is easy to get started (approx. 50 minutes). Although I had some problems:

  • You will have to set the bounds of every component explicitly – this makes it really ugly if it comes to computer generated interface (e.g. Strings withing Labels).
  • It is not easy to display dynamically generated images to the client. Unlike echo and wings, we need here an ImageServlet for this work like e.g. in JSP and GWT.
  • And I had to use the Button class to display an image, because the Image class does not work. This was the reason that it took relatively long to get it working.


Additional Information:

  • If an exception raises you will get a window with the message and a full stack trace!
  • User Libraries: ‘Thinwire’, ‘WebGnuplot’ and ‘Servlet API’ (See the resources section)
  • I needed an extra servlet, which returns the image as an OutputStream
  • License: LGPL


In Wicket you will only be successful, if you know some basics in HTML. You will embed the components via HTML tags and access them from Java via id’s. Although it seems to be complicated I got it within one hour. Maybe that was because of the provided example from JFreeChart forum. I think Wicket will integrate well in existing environment based e.g. up on pure Servlets or JSP.


Additional Information:

  • User Libraries: ‘Wicket’ and ‘WebGnuplot’ (See the resources section)
  • License: APL 2.0


It was even a little bit easier than Echo to get started (less than 20 minutes), because there is a class SImageIcon which takes a BufferedImage as parameter in one of its constructors. So I haven’t to use the documentation – I just used auto-completion of the IDE.

You will get a typically ‘waiting cursor’, if the respond of the server takes too long. My feeling was that WingS was a little bit slower than e.g. Echo with the task of displaying the image after I pressed the button.

Here is the result:

WingS Result

Additional Information:

  • User Libraries: ‘WingS’ and ‘WebGnuplot’ (See the resources section)
  • License: LGPL


It took relative long to get started. 3 or 4 hours. Now I know the steps you have to do:

  1. You will have to understand how to create a zul file for your UI. But there is a demo application on the web site, where you can find a common usage of every component.
  2. You will have to understand how to get information from the client via Path.getComponent(“/zkWindow/error”); and
  3. how to push the results to the client via:
    AImage image = new AImage(“Image”, bytes);

But after understanding how zk works, it was easy for me to create the necessary classes and zul files. The default layout is very nice I think. But please look here for yourself:

Additional Information:

  • User Libraries: ‘ZK Framework’ and ‘WebGnuplot’ (See the resources section)
  • License: GPL or Commercial


You can find all examples as Eclipse projects here. All my code stands under public domain if not otherwise stated. So you can do what you want with them (I.e. for all purposes: commercial etc.).

Try the following procedure to get it working:

  • Install gnuplot and adjust the command line in de.wg.core.GnuplotHelper e.g. for windows it is C:\GPpath\gnuplot.exe I think (I used linux).
  • Then you will need a webserver (I used tomcat) and adjust the location of your webapps folder in all the build.xml files.
  • Build the WebGnuplot project to create the jar in the dist folder (run the build task of build.xml) and change the location of this project in all examples (ant/build.xml).
  • Build all the examples: just run all the ‘build’ ant tasks.

I splitted the examples into several eclipse projects to avoid conflicts (e.g. more than one project uses beanshell) and to compile them independently.

You will have to set up the user libraries for Eclipse to make auto-completion possible. You should put the project specific JAR-files into a subdirectory ‘lib’ of every project.

Define the following user libraries:

  • WebGnuplot: WebGnuplot.jar
  • Servlet API: servlet-api.jar e.g. from tomcat’s common/lib folder.
  • Click: 1 file, 1.8 MB, version: 1.4
  • Echo: 3 files, 0.457 MB, version: 2
  • GWT: 3 files, 11.8 MB, version: linux-1.4.61
  • Thinwire: 2 files, 0.481 MB, version: 1.2 RC2

  • Wicket: 23 files, 8.2 MB, version: 1.3.2

  • WingS: 5 files, 2.3 MB, version: 3.2

  • ZK Framework: 31 files, 19.9 MB, 3.0.3

Maybe you have some usage from the following list, which is based on information from ohloh:

  • Click with 1-3 developer
  • Wicket with at least 4 developer
  • GWT with at least 4 developer
  • Thinwire with 1 developer
  • Echo with 1 developer
  • WingS at least 2 developer
  • ZK Framework at least 5 developer

Please correct my assumptions if I they are wrong!

You can find a slightly modified version of this article on javalobby, where it is also possible post comments.


And the winner is …. my brain, hehe.

But which project is the best one? It depends! Do you need commercial support? Do want to integrate it into an existing project e.g. with a pure Servlet solution? Do you want to integrate the UI tests in your regular tests? And so on.

Try the examples or look into the source to get a feeling of ‘how to work’ with a specific framework.

I hope you will have fun!

First Steps in Eclipse

Why Eclipse?

Some days in the past I decided to try out eclipse 3.3.2. A lot of people are using it here in Germany and especially companies develop new plugins for it – it is a kind of an industry standard. I always felt a little bit hassle when people are talking about eclipse and say it is better than NetBeans. I only knew NetBeans, so I didn’t know if and where they are right and where not. So this blog entry collects some experiences I made while exploring eclipse.

Please, feel free to post your favorite eclipse feature as a comment.

Day 1

I explored the following features:

  • Generating the serialVersionUID for serializeable classes – just with one click (CTRL+1).
  • Spell checking while editing! Very useful!!
  • Eclipse suggests possible keybord bindings if you e.g. type SHIFT+ALT+X. This is especially useful for newbies or for discovering features of e.g. new versions.
  • I have the feeling that the startup is faster and the GUI is more responsive in the first minutes (compared to NB 6.0), although sometimes something strange happens and the IDE freezes for several ten seconds (?).

and the following drawbacks:

  • Fat size for pure Java Developer package (approx. 80 MB for gtk download)
  • For every OS you have to download another package (there is and will be no such OS independent zip, because eclipse is based on SWT, right?)
  • I don’t understand the workspace concept -wherefor we need it?? My friend Gregor explained it to me. If you have several big projects, where each big project has several eclipse projects. Then every big project gets its own workspace, which can save different properties, like default JDK etc.

Day 2

My friend Gregor – the author of Moonlight | 3D – explained me some more details of eclipse. Thanks to him, again!


  • Formatting of Java (or xml) code can be done via CTRL+SHIFT+F. But here the greate difference to netbeans is that you can define different formatting styles for each project and apply them via this keyboard shortcut! Access this via: Right click on the project->Properties->Java Code Style-> Formatter->Enable project specific settings
  • It is possible to add necessary and remove unnecessary imports via CTRL+SHIT+O. The great thing here is, that you can apply this action on several files easily. Via clicking on a package (with several files in it) and press the short cut (or right click the package->Source->Organize Imports). The same is true for formatting the source code.
  • If you want that the debugging will break on every exception (dynamic breakpoint creation), then enable this via: (Menu) Run->Add Java Exception Breakpoint
  • Update process can be done in background (Update via: Help->Software Updates)
  • Mylyn is a great tool for bug tracking. You will indirectly assign source files to bug reports.
  • There are several plugins available; even commercial. And a lot of vendors publish there adapted version of the eclipse IDE to make it easier for the user.


  • The plugin and distribution hell – there are a lot of plugins, which are useful for basic Java development, but are not installed per default. E.g. the VE (Visual Editor for Swing or SWT development) is currently not available for eclipse 3.3.
  • There is a profiler, but Gregor means that it is the hell to run it (compared to the netbeans one.)

Good to know:

  • TPTP = Test Performance Tools Platform
  • Feature Overview via Help->About Eclipse Platform->Feature Details. A feature is a set of plugins.
  • Execute a Java program via F11 and debug it with CTRL F11.
  • Rename a variable (etc.) with ALT+SHIFT+R
  • Subversion via right click on the project->Team. Then: ‘Share…’ means import into a new repository. You can install Subclipse or Subversive to use this.
  • Find Usage via ‘References’ (Right click in the source editor)
  • There are two preferences of the Java editor: Window->Preferences->Java->Editor->General->Editors or Window->Preferences->General->Editors


Eclipse is a nice IDE for Java development and now I know why people are happy with eclipse, although I think NetBeans offers a compareable rich set of features. Maybe every IDE has its scope of usage. I think the reason for the ‘IDE war’ is not that one tool is better than another (this would be too easy), but it is more a war of some people to legitimate their laziness to NOT trying the other IDE(s) in detail. A future candidate for me is definitely IntelliJ, which is free for open source projects.

For some great video tutorials look here.

Eclipse and Spring in Small Doses


Today I will write about a tutorial for spring and eclipse beginners. The original ‘Spring in Small Doses’ was posted here from Tiago Brito Spindola. Because I never really used eclipse I will try to describe additional steps, which will be necessary for eclipse newbies and I hope someone could benefit from it.I am a NetBeans user from 3.4 on, so I hope exploring eclipse features will be interesting and fun. For a nice comparison look here.

I chose the spring-tutorial, because the title suggested it could not get really difficult. As you will notice later the sources are well organized and you will learn concepts like ‘dependency injection’, too (if not already done).

Lets Start With The First Example

Download the four necessary things described in the tutorial:

Some questions related to eclipse arises in the following order, while I go through this example.

At the very first you have to define some user libraries.

How can you define user libraries with eclipse?

With Window->Preferences; Java->Build Path->User Libraries. (You could search within this window – nice!) you can do this.

Hint: I couldn’t find derby in the jdk path, but you can get the latest version here (I used By the way: what is a workspace? Why you need it? If you have multiple projects opened? Or why?

Now it is time to compile the example files. To do so, you have to import the existing sources into eclipse.

How can you import existing projects?

  1. Window->Show View->Other; Search for ‘Project’->Select ‘Project Explorer’
  2. Right click into the window and click ‘import’
  3. Expand the ‘General’ node and select ‘Existing Projects into Workspace. Press ‘next’.
  4. Browse to the location of the root of example one and press ‘Finish’.

Now you are done with it and can close the project via right clicking on the project node and click ‘Close Project’. Go further with

The Second example

Import ‘Report Engine – Part 2’ like described above and right-click the root node of this project. Now go to ‘Run As …’->Java Application and choose ReportViewerStarter as main class. Or type Shift+Alt+x and then j – you will see a popup menu with all possible key combinations before you will type the ‘j’ – this is a nice eclipse feature to learn key bindings! Now you can type in countries and you will see some content in the table.

If you select SpringReportViewerStarter you will see the same frame – but it is different! Because now the sources doesn’t directly rely on the spring libraries!

Go on with

The Third Example

In this part the author of the original tutorials wants to use a database table instead of the file for the country data. You would say: ‘ups I will recreate the program from the scratch or what !? No, this is not necessary, because the author created the program with this ‘feature’ in mind and uses the spring libraries. But maybe he wouldn’t have this in mind – we always benefit from spring, because we decouple implementations from interface and the implementation even could change while running the program. So with spring libraries you are very flexible for later changes.

You will only need some changes to the configuration files and add a new jdbc factory class.

For this example you have to fill the database (derby) with some values. Derby is a really nice, small, powerful and secure database. I used it for my own projects.

How to set up derby?

Find the ‘derby.xml’ file in the ant folder. Then proceed as follows:

  1. Start the server with: Right click derby.xml and ‘Run As’->’Ant Build…’; Deselect ‘usage’ and select ‘start’. Then click ‘Run’. It is possible that you have to set the property derby.home to e.g. /home/peter/programs/derby. You can do this in this (ant-build) dialog: select the tab ‘Properties’ and deselect ‘Use global properties ..’. Then click ‘Add Property…’ and type in your necessary value for the folder.
  2. Fill the database via right-clicking on derby.xml and then click ‘Run As’->’Ant Build…’. Deselect the ‘start’ item and select ‘create’. Then click ‘Run’. You should get the following message: ‘246 of 246 SQL statements executed successfully’ after some hard disc activity.
  3. Now run it as a Java-App: ‘Run As …’->Java Application and choose SpringReportViewerStarter as the main class.

Now, if you are finished, close the project and go on with

The Last Example

In this example you will again benefit from the ‘dependency injection’ pattern, because you will write a web GUI (via JSP) to query the database (-server).

Before building the war file you will have to set the properties spring.home and derby.home to an appropriated value. This was described in the previous example.
Now we can build the war file: Right click the build.xml file and choose ‘Run As’->’Ant Build’.

But how you can deploy a war file?Copy the war file to TOMCAT_HOME/webapps/. Go to the tomcat 5.5. folder where you decompressed it. Go deeper into the ‘bin’ folder and start tomcat:

JRE_HOME=/usr/java/latest && ./startup.sh
(In my case I had to change the default java home directory – thatwhy I added the JRE_HOME stuff.) Then go to: http://localhost:8080/ with your firefox browser 😉 and you will see the typical tomcat start page. If you seek for a better solution to handle deployment, this eclipse plugin could be useful for you. Another kind of deploying is to go to the ‘Tomcat Manager’ on the left of the side and then upload the war file. For this procedure you will need to set up a user with manager privileges. To do this go to the folder: conf/tomcat-users.xml and insert the following line, which ‘creates’ a user called ‘manager’ with manager privileges and mmaa123 as the password:

<user username=”manager” password=”mmaa123″ roles=”manager”/>

Now with the browser go to:


And you will see the list of countries as html in your browser.

The author even implements the Swing GUI for this example, i.e. the report engine will be running on the top of tomcat and the data will be transferred through a spring library. For this you should run the project as Java Application and choose SpringReportViewerStarter. If you don’t believe it, you can shut down tomcat via ./shutdown.sh. Then you will get a RemoteConnectFailureException if you click on the ‘Refresh’ button within the Swing GUI, which indicates that the program really needs tomcat 😉


I hope I could show you how to get started with eclipse and furthermore the author of the ‘Spring in Small Doses’ could show you how to get started with Spring.

Finally I want to thanks Tiago Brito Spindola for his tutorial. For me his tutorial was very easy to follow, although I am an eclipse beginner.

Maybe other users know a better way of doing things in eclipse. Please let me know and feel free to leave your comments here.