2

Possible Duplicate:
How can I run a Windows GUI application on as a service?

I have added code for enable SystemTrayIcon for Windows 7. It is working fine with NetBeans application mode, while I am executing the application in windows services mode it is not working. Please find below code for your reference.

if (!java.awt.SystemTray.isSupported()) {    
                    System.out.println("SystemTray is not supported");    
                return;    
            }    
                final PopupMenu popup = new PopupMenu();    
            Image img1 = new ImageIcon(DataReporter.class.getResource("/lookandfeel/data/xear_appIcon_16.png")).getImage();    
            ImageIcon icon = new ImageIcon(img1);    
                final TrayIcon trayIcon = new TrayIcon(icon.getImage());    
                trayIcon.setToolTip(DataReporterProps.softwareDescriptionText);
                final java.awt.SystemTray tray = java.awt.SystemTray.getSystemTray();    
                MenuItem aboutItem = new MenuItem("About");    
                popup.add(aboutItem);
                trayIcon.setPopupMenu(popup);    
                try {    
                tray.add(trayIcon);    
            } catch (AWTException e) {    
                System.out.println("Cannot add the TrayIcon!");    

            }

Please let me know if any code wants to be added for triggering in windows service mode.

Community
  • 1
  • 1
Sharab
  • 41
  • 1
  • 1
  • 4
  • Thanks for reply Jarnbjo, Actually am using installanywhere software for creating my application in exe formate. Once i created exe i will execute that exe in windows services mode. There system trayicon is not comming. – Sharab Jan 21 '13 at 17:15
  • 2
    And what difference do you think it makes how you package the service? – jarnbjo Jan 21 '13 at 17:18
  • installanywhere software will take care of installing application in service mode. – Sharab Jan 21 '13 at 17:23
  • in netbeans by adding this code it is working fine.By Using InstallAnyWhere software wrapping the application in exe formate. Executing that Exe file in service mode it is not triggering. – Sharab Jan 21 '13 at 17:41
  • What exactly did you not understand of what I have written? A Windows service cannot access the GUI. It is completely irrelevant which tools you have used to create or package the service. – jarnbjo Jan 21 '13 at 17:51
  • But the same is working fine in windows XP.. Mean after wrapping to exe installing that exe in windows xp OS it is working fine.. the same code is not working for windows 7. – Sharab Jan 21 '13 at 20:29

0 Answers0