Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to raise user notifications in Ubuntu using Java code?

share|improve this question
This is more of a coding question. I found this on SO:… – Rinzwind Sep 20 '13 at 13:17

You can use java-gnome, a java binding for GTK and GNOME to display notify-osd notifications. You'll need to install the library first:

sudo apt-get install libjava-gnome-java libjava-gnome-java-doc   

Here is a quick example:

import org.gnome.gtk.Gtk;
import org.gnome.notify.Notification;
import org.gnome.notify.Notify;

public class notifyTest {
    public static void main(String[] args) {  

        Gtk.init(args); // initialize Gtk
        Notify.init("Program Name"); // initalize the notification system  

        Notification myNotification = new Notification("Hello world!", "This is an example notification.", "dialog-information"); // create the notification object; // show the notification  



The general format for a notification is this:

Notification someName = new Notification("Summary", "Body", "Icon")  

Both the body and icon fields can be null, but there must be a summary. For a list of icons you can use by default check the Notify-OSD page of the Ubuntu Wiki.

You then call:;  

To display the notification. For more information see the java-gnome Notify and Notification doc pages.

Note: You must have both Gtk and Notify initialized before you can send any notifications.

share|improve this answer
You should do a selfanswered in SO ;) – Braiam Dec 28 '13 at 0:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.