首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

有关于JCOM组件的有关问题

2012-06-19 
有关于JCOM组件的问题最近在学习用Java调用COM组件的事情,在论坛上找到某大虾的帖子:http://topic.csdn.ne

有关于JCOM组件的问题
最近在学习用Java调用COM组件的事情,在论坛上找到某大虾的帖子:
http://topic.csdn.net/u/20090516/15/f21ec850-bc4c-4ab4-bb1c-bc9b95769395.html

我也根据他的例子做了,但是貌似有问题,贴上代码

Java code
import jp.ne.so_net.ga2.no_ji.jcom.IDispatch;import jp.ne.so_net.ga2.no_ji.jcom.ReleaseManager;public class CallDll {    public static void main(String[] args) {        Process();    }    public static String Process() {        ReleaseManager rm = new ReleaseManager();        try {            IDispatch vbcom = new IDispatch(rm, "U8Distribute.iDistribute");            Object[] param = new Object[] { "XXXXX" };            String strRet = (String) vbcom.method("Process", param);            System.out.println("return: " + strRet);        } catch (Exception e) {            e.printStackTrace();        } finally {            rm.release();        }        return null;    }}


出现了异常:
Java code
jp.ne.so_net.ga2.no_ji.jcom.JComException: createInstance() failed HRESULT=0x800401F3L    at jp.ne.so_net.ga2.no_ji.jcom.IDispatch._create(Native Method)    at jp.ne.so_net.ga2.no_ji.jcom.IDispatch.create(IDispatch.java:84)    at jp.ne.so_net.ga2.no_ji.jcom.IDispatch.<init>(IDispatch.java:46)    at com.dcec.call.dll.CallDll.Process(CallDll.java:14)    at com.dcec.call.dll.CallDll.main(CallDll.java:8)


论坛里也有人遇到这样的错误,他只是说接口写错了便没了下文。
希望哪位大虾懂JCOM的指点小弟一二,搜了一天的资料了,还是没个头绪,脑子乱的紧。。。



PS:Java调用组件是用JNI好,还是用JCOM好?

[解决办法]
没有用过。不过觉得还是JNI好!!
[解决办法]
Java code
ReleaseManager rm = new ReleaseManager();        String res = null;        try {            IDispatch vbcom;            vbcom = new IDispatch(rm, "U8Distribute.iDistribute");            Object[] param = new Object[] { *** };            res = (String) vbcom.method("Process", param);        } catch (JComException e) {            e.printStackTrace();            throw new Exception("Jcom调用发生异常" + e.getMessage());        } finally {            rm.release();        }        return res; 

热点排行