[英]Executing command line app
我正在尝试从代码对类文件执行 JAD 反编译器:
Process p = Runtime.getRuntime().exec("c:\\1\\jad.exe c:\\1\\EIn.class");
//All paths are correct, "c:\\1\\jad.exe c:\\1\\EIn.class" wotks when I run it in cmd
当我调试时,我没有收到任何错误,调试器移动到下一行...
如果我把:
int res = p.waitFor();
它只是挂起。
更新:
BufferedReader in = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String str = null;
while ((str = in.readLine()) != null) { //Stucks here
}
jad
反编译器是否正在等待您通过 stdin 输入?
要查看您收到的错误,请使用getOutputStream
和getErrorStream
以查看反编译器正在写出的内容。
您可以使用ProcessBuilder
类使重定向流更加愉快。
public static void main(String[] args) throws Exception {
String[] cmd = { "c:\\1\\jad.exe", "-c:\\1\\EIn.class" };
Process p = Runtime.getRuntime().exec(cmd);
p.waitFor();
}
这是 Java 中的陷阱,请看一下这个页面,你会得到比你想要的更多!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.