Introduction to Java Gnome

About this tutorial

This is an introductory Java Gnome programming tutorial. The tutorial is targeted for the Java programming language. It has been created and tested on Linux. The Java Gnome programming tutorial is suited for novice and intermediate programmers.

You can download images used in this tutorial here.

Java Gnome

Java Gnome is a wrapper over the GTK+ and Gnome for the Java programming language.

GTK+ is a library for creating graphical user interfaces. The library is created in C programming language. The GTK+ library is also called the GIMP Toolkit. Originally, the library was created while developing the GIMP image manipulation program. Since then, the GTK+ became one of the most popular toolkits under Linux and BSD Unix. Today, most of the GUI software in the open source world is created in Qt or in GTK+. The GTK+ is an object oriented application programming interface. There are several bindings to other programming languages. Language bindings exist for C++, Python, Perl, Java, C# and other programming languages.

GNOME is a desktop environment, the graphical user interface which runs on top of a computer operating system. It is an international project that includes creating software development frameworks, selecting application software for the desktop, and working on the programs which manage application launching, file handling, and window and task management. GNOME is part of the GNU Project and can be used with various Unix-like operating systems. (wikipedia.org)

Tips for development

Do use the official Sun JDK. Don't use any other derivatives or alternatives. You have been warned.

Download the latest version of the Java Gnome library. Compile and install it manually.

./configure --jdk=/home/vronskij/bin/jdk1.6.0_11/

If you have OpenJDK or any other non standard Java development kit installed on your system, you run the configure script with the path pointing to the installed Sun JDK.

After you successfully build your Java Gnome library, you should have two files. The gtk-4.0.jar and the libgtkjni-4.0.10.so. In case you have downloaded java-gnome 4.0.10.

There is a long standing issue with launching Java Gnome applications. Normally, you would need to create a script to launch every Java gnome application. According to the website, it is resolved but it did not work for me. I did a workaround by copying the libgtkjni-4.0.10.so where the gtk-4.0.jar is.

$ ls
gtk-4.0.jar  libgtkjni-4.0.10.so 
$ pwd 
/usr/local/share/java

I work with JDeveloper and this workaround solved this issue.

Adding Java Gnome library
Figure: Adding Java Gnome library

When you create a new project in JDeveloper, you need to add the gtk-4.0.jar to the project libraries. From this point, running the application is a simple F11.

Sources

This was an introduction to the Java Gnome library.