0
我使用以下代码从Java应用程序运行Windows命令。我尝试了一些Windows命令,例如:ver
,它和我一起工作。我需要在应用程序中使用的命令是openssl
。我在Windows上工作,所以我为Windows下载了openssl
。我在命令行窗口中尝试了以下命令,并且它工作正常。但是,当我从Java应用程序尝试它时,我所得到的就是完成。我没有得到输出。任何人都可以帮忙吗?如何从java应用程序运行openssl命令
下面是代码:
import java.io.*;
public class DebianChecker
{
public static void main(String args[])
{
try
{
Process p=Runtime.getRuntime().exec("cmd /c openssl s_client -connect
gmail.com:443");
p.waitFor();
BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line=reader.readLine();
while(line!=null)
{
System.out.println(line);
line=reader.readLine();
}
}
catch(IOException e1) {}
catch(InterruptedException e2) {}
System.out.println("Done");
}
}
没有解决问题。 – user1810868