【发布时间】:2013-06-19 15:56:20
【问题描述】:
我正在尝试编写一个程序,它必须在 linux 终端中执行相同的代码:
openssl req -passout pass:abc -subj /C=US/ST=IL/L=Chicago/O=IBM Corporation/OU=IBM Software Group/CN=John Smith/emailAddress=smith@abc.ibm.com -new > johnsmith.cert.csr
在终端中它工作正常,但在 Java 中却没有。 我尝试了类似的方法,但没有结果。
String[] cmd = { "openssl", "req -passout pass:abc -subj", "/C=US/ST=IL/L=Chicago/O=IBM Corporation/OU=IBM Software Group/CN=John Smith/emailAddress=smith@abc.ibm.com", "-new > johnsmith.cert.csr" };
Runtime.getRuntime().exec(cmd);
你能解释一下,我想念什么。在此先感谢。 最好的祝愿安德烈
【问题讨论】:
-
你试过了吗:
Runtime.getRuntime().exec("openssl req -passout pass:abc -subj /C=US/ST=IL/L=Chicago/O=IBM Corporation/OU=IBM Software Group/CN=John Smith/emailAddress=smith@abc.ibm.com -new > johnsmith.cert.csr");? -
您是否发现任何错误?如果是,错误信息是什么?
-
阅读(并实施)所有 When Runtime.exec() won't 的建议。那可能会解决问题。如果不是,它应该提供更多关于失败原因的信息。然后忽略它引用
exec并使用ProcessBuilder构建Process。还要将String arg拆分为String[] args以说明本身包含空格的参数。
标签: java linux terminal openssl