i have created executable jar file of my project built in eclipse. but when i execute that file then it does not display icon on system tray that i have added in project. i am using following simple code.
Image image = Toolkit.getDefaultToolkit().getImage("src/resources/ChatIcon1.jpeg");
PopupMenu Popup = new PopupMenu();
MenuItem exit = new MenuItem("Exit");
Popup.add(exit);
final TrayIcon trayIcon = new TrayIcon(image,"OfficeCommunicator",Popup);
trayIcon.setImageAutoSize(true);
If you do not have Java installed, and the PATH variable is not set correctly, attempts to run a JAR file on Windows or Ubuntu will result in a 'Java not recognized' error. To run a JAR file, you must install the Java JDK or JRE on your computer.
You can create a shortcut for the . jar and then you can change it: Right button >> Properties >> Change Icon.
To load resources from within .jar files please use getClass().getResource(). That will return a URL with correct path.
Image img = ImageIO.read(getClass().getResource("path to image"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With