使用gnome-java的Java程序无法编译

Sam*_*sen 1 java gtk gnome javac

在尝试编译这个小型Java程序时,要使用java-gnome中的Notifier类(从最新的bzr分支构建):

import org.gnome.notify;


class Notifier {

public void Main(String[] args) {

        Notification n = new Notification("Test notification", "Blah.", "");
        n.setTimeout(2000);
        n.show();

    }
}
Run Code Online (Sandbox Code Playgroud)

编译时我得到以下输出:

$ javac -cp .:/usr/local/share/java/gtk-4.0.jar Notifier.java 

Notifier.java:1: package org.gnome does not exist
import org.gnome.notify;
            ^
Notifier.java:7: cannot find symbol
symbol  : class Notification
location: class Notifier
Notification n = new Notification("Test notification", "Blah.", "");
    ^
Notifier.java:7: cannot find symbol
symbol  : class Notification
location: class Notifier
Notification n = new Notification("Test notification", "Blah.", "");
                         ^
3 errors
Run Code Online (Sandbox Code Playgroud)

/usr/local/share/java/gtk-4.0.jar肯定存在于该位置,并且包含已使用的类.怎么了?非常感谢.

Ric*_*ich 5

也许这只是你问题中的一个错字,但输入行应该是:

import org.gnome.notify.*;
Run Code Online (Sandbox Code Playgroud)

请注意尾随星号.

此外,您的main方法应该是静态的.