【发布时间】:2017-07-20 09:09:13
【问题描述】:
我想用 Java 从 DOORS 获取数据。我发现我可以使用 Jacob 运行 DOORS,但它不起作用。即使不使用 Jacob,任何人都可以指导我解决问题吗? 如果有人能给我一些具体的代码,我将不胜感激。
我的代码:
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.*;
String dxlFile = "" + appDir + "\\dxl\\transferTraceInfoToDOORS.dxl";
try {
//Try and get the active instance of doors first
ComThread.InitMTA();
//ActiveXComponent runningDoors = new ActiveXComponent("DOORS.Application");
ActiveXComponent runningDoors =
ActiveXComponent.connectToActiveInstance("DOORS.Application");
if( runningDoors ==null) {
JOptionPane.showMessageDialog(null,
"This application needs an active running instance of DOORS to work,
please fire DOORS up and try again");
System.exit(0);
} else {
runningDoors.invoke("RunStr", "print(\"Testing\");
oleSetResult(\"Finished\")");
//runningDoors.invoke("RunFile", dxlFile);
System.out.println(runningDoors.getPropertyAsString("Result"));
}
} catch (Exception e) {
e.printStackTrace();
} finally {
ComThread.Release();
}
当我使用“Excel.Application”时,此代码运行良好,但使用 DOORS 时它不会检测到活动实例所以我收到以下消息:“此应用程序需要一个活动运行的 DOORS 实例才能工作,请启动 DOORS然后再试一次”。请帮我。我找不到解决方案。
谢谢。
【问题讨论】:
-
你确定dxlFile的路径正确并且存在吗?是否引发异常?
-
没有检测到正在运行的DOORS活动实例的问题。所以我收到了这条消息:“此应用程序需要一个正在运行的 DOORS 实例才能工作,请启动 DOORS 并重试”。