欢迎访问金谷下载网 专业电脑手机游戏绿色软件网站

资讯|最近更新

当前位置:首页软件教程其他综合相关 → 利用cmd对tomcat进行重启操作

利用cmd对tomcat进行重启操作

时间:2012-11-30 00:00:54人气:作者:本站作者我要评论

由于需要在固定的时候对tomcat进行关闭,所以写了个小例子,利用cmd命令对tomcat进行重启


public class Restart {

   public static void main(String[] args) {
       String dir = "C:\\vvv     mmm\\apache-tomcat-6.0.30\\bin\\";


       Runtime run = Runtime.getRuntime();

       String[] command = new String[]{"cmd","/C","call","startup.bat"};
       try {
           run.exec(command, null, new File(dir));
       } catch (Exception e) {
           e.printStackTrace();
       }

       System.out.println("启动");

       try {
           Thread.sleep(30000);
       } catch (InterruptedException e) {
           e.printStackTrace();
       }

       System.out.println("关闭");

       String[] command2 = new String[]{"cmd","/C","call","shutdown.bat"};
       try {
           run.exec(command2, null, new File(dir));
       } catch (IOException e) {
           e.printStackTrace();
       }


       try {
           Thread.sleep(30000);
       } catch (Exception e) {
           e.printStackTrace();
       }


       System.out.println("重启");

       String[] command3 = new String[]{"cmd","/c","start","startup.bat"};
       try {
           run.exec(command3, null, new File(dir));
       } catch (Exception e) {
           e.printStackTrace();
       }

       System.out.println("nihao");

       try {
           Thread.sleep(10000);

           String[] command4 = new String[]{"cmd","/c","call","tskill","cmd"};
           run.exec(command4);
           System.out.println("关闭cmd进程");
       } catch (Exception e) {
           e.printStackTrace();
       }
   }
}

相关文章

  • win11安装不符合要求解决方法

    win11正式版本已经发布,许多朋友都想要入手体验,微软官方就可以直接下载win11正式版iso镜像,win10系统是可以直接打开升级的,非常方便,但是许多朋友的电脑不支持直接升级,在安装wi..
  • win10系统.net3.5安装失败解决方法

    在win10系统安装一些老版本的软件经常会提示要求我们按照.net3.5,一般情况下联网都会自动下载安装,但是许多朋友也会出现安装失败的情况!下面为您分享解决方法! ..

网友评论

关于金谷下载网 | 联系方式 | 发展历程 | 版权声明 | 下载帮助(?) | 广告联系 | 网站地图 | 友情链接

Copyright 2020-2029 JGSC.CC 【金谷下载网】 版权所有 豫ICP备17041013号-5 | 豫公网安备 42033302000245号

声明: 本站所有软件和文章来自互联网 如有异议 请与本站联系 本站为非赢利性网站 不接受任何赞助和广告