我想在我的Java桌面應用程序中構建一個簡單的系統通知。因此,在網絡上進行一些搜索後,我發現JCarrierPigeon庫可以執行此操作。如何在java桌面應用程序中實現系統通知
所以插入後兩個庫我有這樣的代碼:
package prove;
import javax.swing.JFrame;
import net.sf.jcarrierpigeon.Notification;
import net.sf.jcarrierpigeon.NotificationQueue;
import net.sf.jcarrierpigeon.WindowPosition;
public class NOtification {
public static void main(String[] args){
NotificationQueue queue = new NotificationQueue();
JFrame window1 = new JFrame();
Notification note1 = new Notification(window1, WindowPosition.BOTTOMRIGHT, 25, 25, 1000);
queue.add(note1);
}
}
但是,如果我嘗試運行它,我有這樣的錯誤:
Exception in thread "main" java.lang.NoClassDefFoundError: org/jdesktop/animation/timing/TimingTarget
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at prove.NOtification.main(NOtification.java:18)
Caused by: java.lang.ClassNotFoundException: org.jdesktop.animation.timing.TimingTarget
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 13 more
我怎麼固定呢?
是運行時在classpath中的carrierpigeon jar嗎? – vikingsteve
我已經做了,右鍵點擊項目,Propeties然後我添加JCarrierPiegon.jar – bircastri
您還需要包含時序框架jar:[「首先,請確保在您的類路徑中包含時序框架庫。」](http ://jcarrierpigeon.sourceforge.net/) – Fildor