Saturday, December 3, 2011

Eclipse and Unity integration

My EclipseCon proposal was rejected - I guess I have to try harder next time. But the bitter taste of disappointed was quickly eclipsed by the package FedEx delivered yesterday. It was brand new hardware from my future employer - Red Hat - and I felt really flattered.
The most funny thing was that I had been asked to specify which keyboard layout I preferred. And I got a laptop in one box, and a separate keyboard for that laptop. I had to replace it by myself :). If I had known how much hassle such innocent wish can create, I would have chosen the default layout whatever it was.
I still have about 4 weeks before my real job is commencing, so I am playing right now with all things that I think I should know. One of them is calling native code.

And nothing has me annoyed me recently more than this ugly question mark in Unity launcher.

 Quick searching revealed that there is a very easy thing to do (described f.e. here), and I can enjoy now beautiful Eclipse icon in the launcher

and in Lenses
I said that it was a very easy thing - because it actually required creating one file named "eclipse.desktop" in a specific location. I am mentioning it, because adding proper launcher to Eclipse did not appealed to me as something ambitious, so I tried force Eclipse to display progress in the launcher, in the same way as it is done on Windows or MacOs.

Unfortunately SWT does not support that yet. On the other hand, Unity Launcher API is documented quite well, so I tried to create java bindings for that using the simplest approach JNA. JNA is a very powerful library that allows you to call native libraries without writing a single line in C.

So, I have downloaded the JNA libraries, put it into a regular Java Project, and wrote following interface:

Actually the two JNA libraries take care almost about everything. You do not need to worry about f.e. data conversion.
And the actual code that shows progress bar is:

What is worth noticing is the fact that you can access every launcher if you know the name of the *.desktop file. So you can run even a java program that will test if the integration is correct. I got the following effect:

There is still a lot of work to do. I need to remove dependency on JNA - it is licensed as LGPL - and therefore not welcome very warm by Eclipse Community. Then I will try to provide system taskbar for SWT - so it would integrate with Eclipse Jobs framework! I hope to update you soon with results!


  1. You better tell us what the hardware is :)

  2. Lenovo x200 with more RAM than I have ever had in all my computers summarized.
    And a docking station with full HD monitor.

    It's Sunday morning and I really want to work!

  3. Red Hat? What happened to the "piko" (?) company you started to work recently. Have it been taken over by Red Hat as soon as they realized you started to work for them? :)

  4. It is something like that ;-). I announced that I leave IBM, and Mr. Palmisano decided to retire ;-).

    More seriously, that small company you are referring to is just a short adventure - I do actually non-IT work for them.

    I could not live without Eclipse and Linux (and they use Netbeans and Windows ;-) ).