如何实现java 程序的自动重启
runtime
自动重启的bat文件怎么写啊??????????、

解决方案 »

  1.   

    http://www.cppblog.com/biao/archive/2009/06/12/87498.html
      

  2.   

    这样写就可以重启了public class E extends JFrame {    public E(){
    JButton reboot = new JButton("Reboot");

    reboot.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent evt){
        SwingUtilities.invokeLater(new Runnable(){
        public void run(){
        f.setVisible(false);
        f.dispose();
        //f.setVisible(true);
        f = null;
        E.main(new String[1]);  //为了演示特意创建了一个参数
        }
        private JFrame f = E.this;
        });
        System.out.println("Ready Reboot");
        }
        });            this.getContentPane().add(reboot);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    } public static void main(String[] args){
    if (args.length == 1){  //为了演示特意加的判断.
    System.out.println("Reboot Success");
    }

    JFrame f = new E("Reboot Example");
    f.setVisible(true);
    }
    }
      

  3.   

    你做的跟LZ说的根本就不是一会事,他说通过bat实现程序的重启。