请问:如何通过tomcat做web服务,jsp调用服务器上的exe程序,可以调用服务器上的exe作操作~
<%
try
{ out.println("test");
Runtime rn=Runtime.getRuntime();
Process p=null;
out.println("test1");
p=rn.exec("\"F:\\1.exe\"");
out.println("test2");
// Runtime.getRuntime().exec("D:/Program%20Files/Tencent/QQ/QQ.EXE");
} catch (java.io.IOException e){
System.err.println ("IOException " + e.getMessage());
}
%> 这样调起来会有程序启动到后台,然后会有错误日志出来,请问有别的好方法么?
<%
try
{ out.println("test");
Runtime rn=Runtime.getRuntime();
Process p=null;
out.println("test1");
p=rn.exec("\"F:\\1.exe\"");
out.println("test2");
// Runtime.getRuntime().exec("D:/Program%20Files/Tencent/QQ/QQ.EXE");
} catch (java.io.IOException e){
System.err.println ("IOException " + e.getMessage());
}
%> 这样调起来会有程序启动到后台,然后会有错误日志出来,请问有别的好方法么?
应该是不能在服务器上执行的,你上面的调用肯定是在客户端执行的
Runtime rt = Runtime.getRuntime();
Process p = null; try{
p = rt.exec("tar -xvf a.tar"); p.waitFor();//wait
System.out.println("ok");
}
catch (Exception e){
System.out.println("Error exec tar");
}
把包tar开,然后程序等待tar结束。。
public static void main(String args[]){
Runtime rn=Runtime.getRuntime();
Process p=null; try{
p=rn.exec("\"\\\192.168.1.5/documents/xyhr-setup/j2sdk-1_4_2_10-windows-i586-p.exe\"");
}catch(Exception e){
System.out.println("Error exec AnyQ");
}
}
} 这样的程序可以执行么?