Remote desktop to shutdown
<p>I made a program to monitor the active machines in a networked place and perfectly displayed the IP addresses to JList(jList1). When I clicked one of the IP address that is on the list then right clicked the mouse, a JPopupMenu will appear with a menu of "Shutdown". When i tried to click the "shutdown" menu from the popup menu there's an error displayed, says:</p>

<pre><code>Apr 14, 2011 1:57:07 PM UsernamePasswordPackage.NetCafeTime$9 actionPerformed SEVERE: null java.lang.RuntimeException: Unsupported operating system.
        at UsernamePasswordPackage.NetCafeTime.shutdown(NetCafeTime.java:359)
        at UsernamePasswordPackage.NetCafeTime$9.actionPerformed(NetCafeTime.java:444)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
        at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
        at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:809)
        at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:850)
        at java.awt.Component.processMouseEvent(Component.java:6267)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
        at java.awt.Component.processEvent(Component.java:6032)
        at java.awt.Container.processEvent(Container.java:2041)
        at java.awt.Component.dispatchEventImpl(Component.java:4630)
        at java.awt.Container.dispatchEventImpl(Container.java:2099)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
        at java.awt.Container.dispatchEventImpl(Container.java:2085)
        at java.awt.Window.dispatchEventImpl(Window.java:2478)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
</code></pre>

<p>Codes I used to show popup menu:</p>

<pre><code>public void showProjectMenu(MouseEvent e){
    JPopupMenu menu = new JPopupMenu();
    JMenuItem menuItem;
    menuItem = new JMenuItem("Shutdown");
    menuItem.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent ev){
            //JOptionPane.showMessageDialog(null, "newline");
            try {
                shutdown();
            } catch (RuntimeException ex) {
                Logger.getLogger(NetCafeTime.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(NetCafeTime.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
    menu.add(menuItem);
    menu.show(e.getComponent(),e.getX(),e.getY());
}
</code></pre>

<p>Mouse clicked event codes:</p>

<pre><code>   private void jList1MousePressed(java.awt.event.MouseEvent evt) {
    if(SwingUtilities.isRightMouseButton(evt)&amp;&amp;!jList1.isSelectionEmpty()&amp;&amp;jList1.locationToIndex(evt.getPoint())==jList1.getSelectedIndex()){
            showProjectMenu(evt);
        }
    }

    private void jList1MouseReleased(java.awt.event.MouseEvent evt) {
    if(SwingUtilities.isRightMouseButton(evt)&amp;&amp;!jList1.isSelectionEmpty()&amp;&amp;jList1.locationToIndex(evt.getPoint())==jList1.getSelectedIndex()){
            showProjectMenu(evt);
        }
    }
</code></pre>

<p>Codes I used to show the popup menu:</p>

<pre><code>public void showProjectMenu(MouseEvent e){
    JPopupMenu menu = new JPopupMenu();
    JMenuItem menuItem;
    menuItem = new JMenuItem("Shutdown");
    menuItem.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent ev){
            //JOptionPane.showMessageDialog(null, "newline");
            try {
                shutdown();
            } catch (RuntimeException ex) {
                Logger.getLogger(NetCafeTime.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(NetCafeTime.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
    menu.add(menuItem);
    menu.show(e.getComponent(),e.getX(),e.getY());
}
</code></pre>

<p>Codes I used to shutdown another pc by it's IP address:</p>

<pre><code>public void shutdown()throws RuntimeException, IOException{
    String shutdownCommand;
    String operatingSystem = System.getProperty("os.name");
    if("Linux".equals(operatingSystem)||"Mac OS X".equals(operatingSystem)){
        shutdownCommand = "shutdown -h now";
    }else if("windows".equals(operatingSystem)){
        shutdownCommand = "shutdown.exe -s -t 0";
    }else{
        throw new RuntimeException("Unsupported operating system.");
    }
    Runtime.getRuntime().exec(shutdownCommand);
}
</code></pre>

<p>Problem is, I cannot get to shutdown the other pc...</p>

<p>Any kind of help would be greatly appreciated and thanks...</p>
