Clase Main

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package apagarmaquina;
import javax.swing.*;

public class ApagarMaquina {

    /**
     * @param args the command line arguments
     */
    
    public static void main(String[] args) {
        // TODO code application logic here
        Comando com = new Comando();
        String tiempo;
        int time = 0;
        String msj = "";

        try{
         tiempo = JOptionPane.showInputDialog("Ingrese el tiempo en segundos!"); 
         time = Integer.parseInt(tiempo);
         msj = "shutdown -s -t "+time;
        }catch(Exception e){
            System.out.println("ERROR");
        }
        System.out.println(msj);
        com.exec(msj); 
    }
}

Clase Comando

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package apagarmaquina;

import java.io.IOException;

public class Comando {
     public void exec(String cmd) { 
        try { 
            Runtime.getRuntime().exec(cmd); 
        }  
        catch (IOException e) { 
            System.out.println("Failed");         
        } 
}
}