Java调用exe,exe在任务管理器中挂起未执行问题解决方法

源码如下: 

在客户端运行正常,但在服务器端运行就出现问题了(使用web调用代理的方式)

import java.io.InputStreamReader;
import java.io.LineNumberReader;

import lotus.domino.AgentBase;
import lotus.domino.Database;
import lotus.domino.Session;

public class JavaAgent extends AgentBase {

 /* (非 Javadoc)
  * @see lotus.domino.AgentBase#NotesMain()
  */
 public void NotesMain() {

  try {
   Session session = getSession();
   Database db = session.getCurrentDatabase();
   String fileName = "xml_dom_javascript.pdf";
   String cmdStr = "cmd /c start D:\\IBM\\Lotus\\Domino\\data\\SWFTools\\pdf2swf.exe";
   String savePath = "D:\\";
   //增加语言包 解决中文乱码问题
   String languagePath="D:\\SWFTools\\xpdf\\chinese-simplified";
   // 要加"" 就是为了防止要转换的过程中,文件夹名字带有空格,导致失败
   String sourcePath = "\"" + savePath + fileName + "\"";
   String targetPath = "\"" + savePath
     + fileName.substring(0, fileName.lastIndexOf(".")) + ".swf"
     + "\"";
   //String argsStr = "  -t " + sourcePath + " -o " + targetPath + " -s flashversion=9 -s languagedir="+languagePath;
   String argsStr = "  " + sourcePath + " -o " + targetPath;
   Runtime rn = Runtime.getRuntime();
   Process p = null;
   String cmd = cmdStr + argsStr;
   try {
    p = rn.exec(cmd);
    /*p.waitFor();
    p.destroy();
    InputStreamReader ir = new InputStreamReader(p
     .getInputStream()); LineNumberReader input = new
     LineNumberReader(ir); String line; while ((line =
     input.readLine()) != null) System.out.println(line);
     */
    System.out.println(cmd);
   } catch (Exception e) {
    System.out.println("Error my exec ");
    System.out.println(e);
   
   }
  } catch (Exception e) {
   e.printStackTrace();
  }

 }
}

说明:

其中起到关键作用的就是cmd /c start 啦,即打开windows 下的命令行窗口

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值