做一个项目时,需要在网页中启动ProE程序,于是就找了一些启动本地程序的代码,程序是这样设计的:在网页加一个按钮,该按钮的onclick事件是跳转到proeAction.do文件(proeAction.do是struts下执行Action动作所需要的跳转链接),然后执行相应的ProeAction.class文件,在ProeAction.class中写了一段调用PreE的程序,结果ProE是能启动了,但只能是在服务器所在的机子上启动,即在客户机上点击这个按钮,启动的不是本地客户机上ProE程序,而是服务器所在的机子上的ProE程序,看来使程序写的不对路,希望高手们能够给我提供一些建议或方法,能有一些示例代码就更好了,多谢了!
以下是程序代码:
public class ProeAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
try
{
String home = "C:/Program Files/proeWildfire 3.0/bin/";//路径这里不能动态的变化也是一个问题
String command = "proe.exe";
File dir = new File(home);
System.out.println("1");
Process p = Runtime.getRuntime().exec(command, null, dir);
System.out.println("2");
StringBuffer strOutput = new StringBuffer();
BufferedReader in = new BufferedReader(new InputStreamReader(p.
getInputStream()));
System.out.println("3");
String strProc;
while ((strProc = in.readLine()) != null) {
strOutput.append(strProc + "\n");
System.out.println("4");
}
p.waitFor();
p.destroy();
}
catch(Exception e){e.printStackTrace();
System.out.println("Something wrong happened");
}
return mapping.findForward("success");
}
}
这些代码是需要修改修改就行了,还是彻底不行,必须换掉才能启动本地程序,希望牛人指教