Category Archives: IDE

QT Application with Java. Possible? Yes QT Jambi does it.

If you’ve never heard about it, you can build rich cross-platform GUIs with Qt Jambi., while coding in Java. What?
Yes, QT Jambi is a QT Binding to Java, allowing you to develop QT GUI using Java instead of C++.
It practically is the same thing as Java-Gnome library which is a GTK+ binding.

QT Jambi is still maintained as opposite to rumors. And the last snapshot was build on 11 November 2012.
If you want to give it a shot, the following is a ‘get started’ tuto:


  • OS: Ubuntu 12.10 AMD64
  • Desktop: Unity
  • IDE 1: Netbeans 7.3
  • JDK: Oracle JDK 1.7.u10
  • IDE 2: Eclipse Juno

First, install Qt Jambi from its PPA:

sudo add-apt-repository ppa:qtjambi-community/libqtjambi-snapshots && sudo apt-get update && sudo apt-get install --install-suggests libqtjambi-snapshot qtjambi-examples-snapshot qtjambi-designer-snapshot ant-qtjambi-snapshot libqtjambi-redist-snapshot

Then, use this script, to tell your JDK where to find corresponding QT libraries used by QT Jambi:


#| Title: CopyJambi
#| Author: Hanine HAMZIOUI
#| Contact: <>
#| Date:  Sat 15 Dec 2012 03:57:00 AM WET
#| License: GNU GPL v3+
#| Description: Create symlinks to QT libs in default JDK for Jambi.
#| Version: 1.0
#| Environment: Netbeans 7.3 on Ubuntu 12.10 AMD64
#| Compliance: bash, zsh, ksh, dash, sh

# sudo add-apt-repository ppa:qtjambi-community/libqtjambi-snapshots
# sudo apt-get update
#sudo apt-get install --install-suggests libqtjambi-snapshot qtjambi-examples-snapshot qtjambi-designer-snapshot ant-qtjambi-snapshot libqtjambi-redist-snapshot

# Pick the JDK path
if [ -n "${JAVA_HOME}" ]; then jdk=${JAVA_HOME}
    if [ -d "/usr/lib/jvm/default-java" ]; then jdk=/usr/lib/jvm/default-java
    else whiptail --msgbox "No JAVA_HOME was found. Script will abort." "$LINES" "$COLUMNS"; exit 0

# Two Temporary files that receive names of libraries to be copied

# Get the names of libraries to be copied
ls /usr/lib/x86_64-linux-gnu/ | grep libQt | sed -e '/.prl$/g' -e '/.a$/g' -e '/[0-9].[0-9]$/g' | perl -ne 's/^$//g || print' > ${tmp1}
ls /usr/lib/x86_64-linux-gnu/ | tr '[:upper:]' '[:lower:]' | grep libqt | sed -e '/.prl$/g' -e '/.a$/g' -e '/[0-9].[0-9]$/g' | perl -ne 's/^$//g || print' >> ${tmp1}
ls /usr/lib/jni |  tr '[:upper:]' '[:lower:]' | grep trolltech > ${tmp2}
ls /usr/lib/jni |  tr '[:upper:]' '[:lower:]' | grep jambi >> ${tmp2}

# Create symbolic links to QT libraries
while read line; do
sudo ln -v -s /usr/lib/x86_64-linux-gnu/${line} /usr/lib/${line}
sudo ln -v -s /usr/lib/x86_64-linux-gnu/${line} ${jdk}/jre/lib/amd64/${line}
done < ${tmp1}
echo "Copied ${count} QT libraries Symbolic links"

# Create symbolic links to Jambi Libraries
while read inline; do
sudo ln -v -s /usr/lib/jni/${inline} ${jdk}/jre/lib/amd64/${inline}
sudo ln -s -v /usr/lib/jni/${inline} /usr/lib/${inline}
done < ${tmp2}
echo "Copied ${i} Jambi QT libraries Symbolic links"

# Remove temporary files
if [ -f ${tmp1} ] || [ -f ${tmp2} ]
    then rm -v ${tmp1}; rm -v ${tmp2}

# Make sure the user system is amd64
arch=$(uname -i)
if [ "${arch}" = "x86_64" ]; then eval OPERATION
else whiptail --msgbox "Your system architecture is not AMD64. Script will not continue. Abort." "$LINES" "$COLUMNS"
exit 0

The above script will create symbolic links in your JDK path. If you want you can copy the libraries instead of just symlinking them.

Next step is to create a Java Project in Netbeans and import Qt Jambi library in classpath as well as QT Jambi Demos library. (You’ll find them in /usr/share/java/)


Here is a screenshot of a demo example :


You can test with a simpler example (Hello World):

package jambi;

import com.trolltech.qt.gui.*;

public class HellowWorld {

public static void main(String args[]) {
QPushButton hello = new QPushButton("Hello World!");
hello.resize(120, 40);
hello.setWindowTitle("Hello World");;


When running a QT Jambi java file, you might encounter this error :
# A fatal error has been detected by the Java Runtime Environment:
# SIGSEGV (0xb) at pc=0x00007f6b95e362ba, pid=10602, tid=140100171314944
# JRE version: 7.0_10-b18
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.6-b04 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [] QWidgetPrivate::deleteTLSysExtra()+0x3a
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
# An error report file with more information is saved as:
# /home/hanine/Workspace/test/jambi/hs_err_pid10602.log
# If you would like to submit a bug report, please visit:

Yet, entering : ulimit -c unlimited does not help at all. It sounds like an old bug related to Java HotSpot, where a zip file is read and modified in the same time. In other situations this bug is overriden using -Xmx option (e.g. -Xmx2900m : Maximum Memory : 2.9 GB )
E.G: java -Xmx:1864m -Xms:1864m myapp.jar sets minimum & maximum java memory heaps to 1864 MB for myapp.jar.
So, it appears that in almost all cases, a java file with the following statements will produce this error:

 public static void main(String args[]) {

        Wiggly d = new Wiggly(null);;


So to get rid of this error, change the code to look like this instead (Still investigating on the root problem though):

 public static void main(String args[]) {
        new Wiggly(null).show();


Running your Qt Application from terminal

When you clean and build with Netbeans, you’d get a Jar File in your project workspace, in a folder named dist.
Make this jar file executable : chmod +x /path/to/this/jar/file.jar
and run it from terminal: java -jar /path/to/this/jar/file.jar

Qt Application executed as a JAR file.

Qt Application executed as a JAR file.

Eclipse Juno IDE

You can achieve the same thing using Eclipse if it’s your preferred IDE. Just make sure you install qt-jambi from Launchpad PPA and run the above script:

  • – Use the script from above or just download it from here : QtJambiCopierSCript
  • – Save it in your Desktop and run : bash ~/Desktop/
  • – Follow instructions if any.
  • – Open Eclipse Juno, Create a Java Project and add external libraries from /usr/share/java/
  • – Adding the qtjambi.jar and qtjambi-examples.jar does the job.


GUI Designer

Unlike Java-Gnome binding library which does not yet integrate with GUI designer GLADE, Qt Jambi integrates with QT Designer.
If you followed instructions above, go to your Terminal and type:


bash /usr/bin/

This will launch QT Jambi Designer. Henceforth, you can start designing visually your GUI. Once finished, save the work as a "*.jui" file, which you would reuse as your Application UI.
Normally, Qt Designer produces a file with "*.ui" extension; but QT Jambi team has modified the thing with custom modifications that allow better integration and generation of UI java files.
We will cover this later in this same post.
Thanks for reading.
N.B: Qt Jambi Community website is down since yesterday (14th December).
You can browse other useful resources that will get you accustomed to QT Jambi quickly: QT JAMBI RESOURCES


Integration of Java Swing Applications with Unity Global Menu in Ubuntu 12.04

Java Swing Ayatana – Ubuntu Global Menu Support

Thanks to the new Project named Java Ayatana (Initiated by Jared Gonzales), Java Swing applications developers can now add support for Ubuntu Unity Global menu integration and Unity Launcher (Only one instance of Netbeans entry will be allowed in the Launcher and will persist despite logout or reboot).

All you have to do is import the Java Ayatana Library to your Java project CLASSPATH and call it in your Main JFrame object Class.

Java Ayatana Library in Classpath (Netbeans)

Java Ayatana Library in Classpath (Netbeans)

* It is necessary for javax.swing.JFrame to
* include a menu bar javax.swing.JMenuBar object.
import javax.swing. *;

 public class Window extends JFrame {
public Window () {
/ / Setup window ...
// Check if Ayatana Desktop is supported
ApplicationMenu.tryInstall (this);
  • Here is a JFrame example that you can use to test Java Ayatana:

package swingtest;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

* Java Ayatana: Java Swing Global Menu Support in Ubuntu
* @author Hanynowsky
public class MenuBarExample extends JFrame {

* Constructor
public MenuBarExample() {

// Components
String s = "I am a basic example of Java Swing Menu Bar"
+ " that uses Java Ayatana Library: Java Swing Support for Unity "
+ "GLobal Menu in Ubuntu";
final JTextPane textarea = new JTextPane();
Font font = new Font("Liberation Mono", Font.PLAIN, 14);
setSize(500, 350);
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
JMenu editMenu = new JMenu("Edit");
JMenu viewMenu = new JMenu("View");
JMenuItem newAction = new JMenuItem("New");
JMenuItem openAction = new JMenuItem("Open");
JMenuItem exitAction = new JMenuItem("Exit");
JMenuItem cutAction = new JMenuItem("Cut");
JMenuItem copyAction = new JMenuItem("Copy");
JMenuItem pasteAction = new JMenuItem("Paste");
JMenuItem toolbarsAction = new JMenuItem("toolbarsAction");
exitAction.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
newAction.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
System.out.println("You clicked on the new action");
textarea.setText("What did you expect by clicking me! A new cake?");

* Main Method
* @param args
public static void main(String[] args) {
MenuBarExample mba = new MenuBarExample();
// Java Ayatana Call
if (AyatanaDesktop.isSupported())
{ ApplicationMenu.tryInstall(mba);}

  • And the result is this:
Global Menu Support in Java Swing (Java Ayatana)

Global Menu Support in Java Swing (Java Ayatana)

And HUD:

HUD Integration

HUD Integration

NetBeans IDE 7.1.2 Support

: Global Menu & Unity Launcher

Let’s also note that the same library is used into a NBM plugin for Netbeans IDE, updated for version 7.1.2. You can get the plugin in Java Swing Ayatana google code repository.

Open your Netbeans IDE, then: Options / Plugins. And add the downloaded plugin and then install it (Restart NetBeans). You can also install it using the catalog XML file retrieved from :

After Installation, if the plugin does not work, Go to : /home/yourUserName/.local/share/applications/

and check if there is a file : netbeans-7.1.2.desktop

Open it with your text editor (ex: gedit). It should be similar to this.

[Desktop Entry]

N.B: The property ‘Exec=netbeans‘ assumes that you are already able to run NetBeans in Terminal using the command : netbeans instead of the whole path to netbeans executable.
Finally, drag the same file to your Unity Launcher, if not yet done.

Netbeans Integrtion with Ubuntu Unity Global Menu & Launcher

Netbeans Integrtion with Ubuntu Unity Global Menu & Launcher

Netbeans Integrtion with Ubuntu Unity HUD

Netbeans Integrtion with Ubuntu Unity HUD


SOLUTION 2 :  JRE endorsed.

Today, you can set your default JRE (Java Runtime Environment) (Oracle JRE or OpenJDK JRE) to call Jayatana whenever the VM is run by  a swing application.

You no more need to import the Jayatana library into your Swing project classpath. Now, execute your swing application in ubuntu and it’s automatically integrated with Global Menus.

What to do?

Depending on your JDK of choice, here are the appropriate steps to follow:

OpenJDK JDK 7:

On Terminal enter, one comand by one:

Switch to your home directory:

cd ~/

Install the required packages

sudo apt-get install openjdk-7-jdk libunity-dev libxt-dev gcc make ant subversion

Update Java alternatives (set OpenJDK as default)

sudo update-java-alternatives -s java-1.7.0-openjdk-amd64

Use Subversion to checkout Jayatana source code (this will copy the library source code to your home folder).

svn checkout

switch to the newly created folder (/jayatana)

cd ~/jayatana

Use ANT to unbuild the project if already built.

sudo ant deinstall

Use ANT to build and configurate the project

sudo ant install
sudo ant config


sudo apt-get install openjdk-7-jdk libunity-dev libxt-dev gcc make ant subversion
svn checkout
cd ~/jayatana
sudo ant deinstall
sudo ant install -Djava.home.7=/usr/lib/jvm/oraclejdk7
sudo ant config -Djava.home.7=/usr/lib/jvm/oraclejdk7

Where /usr/lib/jvm/oraclejdk7 is your JDK_7 home directory.

The following screenshot illustrates Intellij IDEA Global menu integration in Ubuntu 12.10 using SOLUTION 2.




Semi-Automatic Installation

If you want to automate the Jayatana installation, you can use or download this script below as follows:
– Copy/Paste the script content in a file and name it :
– Save the file in your Desktop folder.
– go to Terminal and type: sh ~/Desktop/– Follow instructions.
– Later on, if you want to uninstall Jayatana, use the same script again.


# ----------------------------------------------
# Author:
# Before executing this script make sure 
# you're in your home directory `cd $HOME`

# -------------------------------------NOTICE------------
# This script installs Jayatana for your JDKs 
# It supposes you already have set your JAVA_HOME in ~/.bashrc
# You will be prompted to choose which JDK to set as Default 
# (choose the corresponding index).
# In case you already installed jayatana and want to re-install, 
# please uninstall then install again.
# ------------------------------------------------------

# -------------------------------------LICENSE--------------------
#Licensed under the GNU LGPL, Version 3.0 (the "License");
# you may not use this file except in compliance with the License
# ----------------------------------------------------------------

#JDKPATH=`echo $JAVA_HOME | sed -e 's/bash://g' | sed -e 's/Is a directory//g'`
#JDKPATH=eval "echo $JAVA_HOME"
JDKPATH=`echo $JAVA_HOME | grep [^*]`

sudo apt-get -y install openjdk-7-jdk libunity-dev libxt-dev gcc make ant subversion 
sudo update-java-alternatives -s java-1.7.0-openjdk-amd64 
svn checkout $JAYATANADD 
sudo ant install -buildfile $USERHOME/jayatana/build.xml -v
sudo ant config -v 
sudo update-alternatives --config java 
sudo update-alternatives --config javac
sudo ant install -Djava.home.7=/usr/lib/jvm/java-7-openjdk-amd64 -f $USERHOME/jayatana/build.xml -v -l $USERHOME/Desktop/jayatana-stall.log
sudo ant config -Djava.home.7=$JDKPATH -f ~/jayatana/build.xml -v -l $USERHOME/Desktop/jayatana-stall.log

sudo ant deinstall -buildfile $USERHOME/jayatana/build.xml -v
sudo ant deconfig -buildfile $USERHOME/jayatana/build.xml -v
sudo ant deconfig -Djava.home.7=$JDKPATH -f $USERHOME/jayatana/build.xml -v -l $USERHOME/Desktop/jayatana-stall.log

# DELETE Jayatana Folder created by subversion checkout
read -p "Delete Jayatana Folder too? Enter ( y ) to delete or ( n ) otherwise : " choice
if [ "$choice" = "y" ]; then mv $HOME/jayatana $HOME/.local/share/Trash/files/
elif [ "$option" = "n" ]; then echo"Jayatana Folder is kept by $USER";
echo "you can delete it later : ~/jayatana";
else echo "Jayatana Folder is kept by $USER , you can delete it later : ~/jayatana";

echo "$JDKPATH : is your default JDK. Version: " 
echo `java -version`
eval COMMON;
read -p "Enter ( i ) to install or ( u ) to uninstall : " option
if [ "$option" = "i" ]; then eval INSTALLCOM
elif [ "$option" = "u" ]; then eval UNINSTALLCOM;eval UNDIR;
else echo "Aborted by $USER";
exit 0;


  • Netbeans IDE: You will lose launcher icon consistency (Unless you install jayatana netbeans plugin jayatana.nbm).
  • Oracle JDeveloper 11g R2: No integration yet. Still a mystery.
  • HUD: In order to benefit from Unity HUD for Java Swing applications, you need to manually create a myjavaapp.desktop file and put it in ~/.local/share/applications/


[Desktop Entry]
Exec=java -jar /home/myusername/mySwingApp/mySwingApplication.jar
Name=MySwingApp 1.2


For Open JDK :
cd ~/jayatana && sudo ant deinstall && sudo ant deconfig
for Oracle JDK:
cd ~/jayatana && sudo ant deinstall && sudo deconfig -Djava.home.7=ORACLE_JAVA_HOME_7
where ORACLE_JAVA_HOME_ is your JDK home directory (most likely /usr/lib/jvm/myjdk7)

Eclipse IDE’s Ubuntu Integrated Menus Hack


Eclipse Icon

 Eclipse IDE is blacklisted in the general application menu library ( in Ubuntu- as well as other applications like EMACS editor and Lotus Note -. We don’t know exactly why! But it seems Eclipse could show corrupted menus (disordered menus, missing menus, duplicate menus…). Real technical explanations are not yet provided. At lease for Emacs IDE, we know that when integrated to Global Menu, dynamically created menus do not integrate (try to same procedure below for Emacs – replace emacs23 by Xemacs23 – and you would notice that sh-Script menu is lost).
As a matter of fact, when you open Eclipse IDE, menus are not integrated in top panel, and one cannot use HUD for Eclipse neither. For developers who migrated from Mac Os to Ubuntu Unity, this could feel ugly. For the time being, there is a hack that enables integration of Eclipse IDE’s menus in Unity top panel, and as far as we can tell, there is no downside until now. However, feel free to report if any!

Continue reading