public static void main(String[] args) {

    if (SystemTray.isSupported()) {

      PopupMenu popup = new PopupMenu();

      MenuItem i1 = new MenuItem("Now!");
      i1.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
          myThread.interrupt();
        }
      });
      popup.add(i1);
      MenuItem i2 = new MenuItem("Exit");
      i2.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
          alive = false;
          myThread.interrupt();
        }
      });
      popup.add(i2);

      SystemTray tray = SystemTray.getSystemTray();
      imageIdle = Toolkit.getDefaultToolkit().getImage("./icon16.png");
      imageBusy = Toolkit.getDefaultToolkit().getImage("./busy.png");
      imageError = Toolkit.getDefaultToolkit().getImage("./error.png");
      trayIcon = new TrayIcon(imageIdle, "Temperature Control", popup);
      try {
        tray.add(trayIcon);
      } catch (AWTException e) {
        System.err.println("TrayIcon could not be added.");
      }
    }

    instance = new Server();
    (myThread = new Thread(instance)).start();
  }