如何使用java在Linux终端中运行curl

时间:2017-02-09 12:51:47

标签: java

尝试以下:

ProcessBuilder Runtime.exec()

但无法执行?

我的卷曲请求

ProcessBuilder pb = new ProcessBuilder( "curl",
    "-H Content-type: text/xml;charset=UTF-8",
    "-d @acd.xml" , 
    "-k "
    ,"\"https://127.0.0.1:4443/s1/ssdces/dfing/v2\"", 
    "--tlsdv1");

我收到了错误

curl: (1) Protocol "https not supported or disabled in libcurl

但我已经指定-k用于不安全的连接

curl --version curl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.21 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2 Protocols: tftp ftp telnet dict ldap ldaps http file https ftps scp sftp Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz

终端工作正常但是当尝试使用java时它会出现上述错误

1 个答案:

答案 0 :(得分:0)

这样的事情可能有用吗?

 Process p = new ProcessBuilder("myCommand", "myArg").start();