关于no office executable found!解决方法

  笔者写了一个简单新建swriter的代码

com.sun.star.uno.XComponentContext xContext = null;
        
        try {
            // get the remote office component context
            xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
            System.out.println("Connected to a running office ...");

            // get the rmeote service manger
            com.sun.star.lang.XMultiComponentFactory xMCF =
                xContext.getServiceManager();

            // create a new instance of the desktop
            Object oDesktop = xMCF.createInstanceWithContext(
                                        "com.sun.star.frame.Desktop", xContext);

            // get the component laoder from the desktop to create a new
            // text document
            com.sun.star.frame.XComponentLoader xCLoader =
                (com.sun.star.frame.XComponentLoader)
                UnoRuntime.queryInterface(
                    com.sun.star.frame.XComponentLoader.class,oDesktop);
            com.sun.star.beans.PropertyValue [] szEmptyArgs =
                new com.sun.star.beans.PropertyValue [0];
            String strDoc = "private:factory/swriter";

            System.out.println("create new text document");
            
            com.sun.star.lang.XComponent xComp = xCLoader.loadComponentFromURL(
                strDoc, "_blank", 0, szEmptyArgs);
        }
        catch( Exception e) {
            e.printStackTrace(System.err);
            System.exit(1);
        }

运行后会报错如下:

com.sun.star.comp.helper.BootstrapException: no office executable found!


解决方案如下:

第一步 下载bootstrapconnector.jar,链接地址为 http://user.services.openoffice.org/en/forum/download/file.php?id=836&sid=12df5c8cdc4d853aa8a6fc87071f922f

第二步 把下载好的bootstrapconnector.jar包放到你安装office后juh.jar的地方

第三步 修改相应的源代码

            xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();修改为:

            String oooExeFolder = "C:/Program Files/NeoShineOffice 5/program/";

           xContext = BootstrapSocketConnector.bootstrap(oooExeFolder);


之后的代码可以保持即可新建一篇字处理文档






  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值