我正在尝试运行这行代码:
Process p = Runtime.getRuntime().exec(new String[] {"nmap -sP 192.168.1.0/24", g});
上面给出了这个错误:
Exception in thread "main" java.io.IOException: Cannot run program "nmap -sP 192.168.1.0/24": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at Test.main(Test.java:14)
但是,这行代码可以正常工作:
Process p = Runtime.getRuntime().exec(new String[] {"nmap", g});
以下是一些细节:
- 安装了nmap 5.51,它可以从“cmd 行”完美运行。
- 视窗.