Runtime.getRuntime()。exec()执行两行? [英] Runtime.getRuntime().exec() execute two lines?

查看:874
本文介绍了Runtime.getRuntime()。exec()执行两行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Runtime.getRuntime()。exec()中运行两行,这两行:

I need to run two lines in Runtime.getRuntime().exec(), this two:

cd %CMS_HOME%
ant deploy

现在可以制作。蝙蝠文件,但我觉得它对两行没用,
更容易!有人有什么想法吗?

Now is it possible to make a .bat file, but I think it is useless for two lines, is muss be easier! Someone any idea?

推荐答案

将其放入 .bat 文件中。这不是无用的;这就是Runtime.exec的工作原理。

Put it in a .bat file. It's not useless; that's just how Runtime.exec works.

您应该考虑使用 ProcessBuilder 类而不是 Runtime.exec()。它是作为 Runtime.exec()的继承者在JDK 5中引入的。

You should look into using the ProcessBuilder class instead of Runtime.exec(). It was introduced in JDK 5 as the successor to Runtime.exec().

这篇关于Runtime.getRuntime()。exec()执行两行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆