文章分类

当前位置:首页>文章中心>服务器相关>java启动服务

java启动服务

发布时间:2022-05-20 点击数:990
	public static void main(String[] args) {
		try {
			String cmd = "net start MySQL57_3306";
			logger.info("执行指令==>{}", cmd);
			Process p = Runtime.getRuntime().exec(cmd);
			InputStream stderr = p.getErrorStream();
			InputStreamReader isr = new InputStreamReader(stderr, Charset.forName("GBK"));
			BufferedReader br = new BufferedReader(isr);
			String line = null;
			while ((line = br.readLine()) != null)
				logger.info("{}", line);
		} catch (Exception e) {
			logger.error("异常", e);
		}

	}