【问题标题】:Convert Apache POI .jar to .dll using IKVM.Net使用 IKVM.Net 将 Apache POI .jar 转换为 .dll
【发布时间】:2012-11-19 11:39:25
【问题描述】:

我正在尝试将 Apache poi .jar 转换为 .dll 。我使用下面的脚本进行转换。但是,在那之后我收到了很多警告和错误 Invalid option -resource:poi-3.8-20120326.dll。这是我使用的脚本。

ikvmc -target:library poi-ooxml-schemas-3.8-20120326.jar
ikvmc -target:library poi-3.8-20120326.jar
ikvmc -target:library -resource:poi-3.8-20120326.dll poi-scratchpad-3.8-20120326.jar
ikvmc -target:library -resource:poi-3.8-20120326.dll poi-ooxml-schemas-3.8-20120326.dll poi-scratchpad-3.8-20120326.dll poi-ooxml-3.8-20120326.jar
ikvmc -target:library -resource:poi-3.8-20120326.dll poi-ooxml-3.8-20120326.dll poi-excelant-3.8-20120326.jar

这是使用 IKVM.Net 的正确方法吗?如果不是,那么执行此操作的正确脚本是什么。

【问题讨论】:

标签: java .net dll apache-poi ikvm


【解决方案1】:

ikvmc compiler is documented-resource 选项如下所示:

-resource:name=path 将路径包含为名为 name 的 Java 资源

所以这似乎表明 -resource 用于将资源文件包含到编译中,而不是(就像您正在做的那样)以前编译的 DLL。

这个怀疑在an example of the ant wrapper around ikvmc 中如何使用resource 选项的示例得到证实:

<resource name="/logs/logging.properties" path="${builddir}/logging.properties"/>

由于ikvmc 是一个java-bytecode-to-.net-intermediate-language 编译器,它知道如何读取jar 文件。因此,与其尝试将(先前生成的)DLL 包含到编译周期中,不如将 ikvmc 指向原始 jar 文件。

最简单的方法可能是一次性转换所有 jar:

ikvmc -target:library poi-ooxml-schemas-3.8-20120326.jar poi-3.8-20120326.jar poi-scratchpad-3.8-20120326.jar ...

【讨论】:

    【解决方案2】:

    您需要将选项 -resource 替换为 -reference。

    但最好是使用 { } 语法一步编译它。请参阅wiki for details。这可能看起来像:

    ikvmc { -target:library poi-ooxml-schemas-3.8-20120326.jar } { -target:library poi-3.8-20120326.jar } { -target:library poi-scratchpad-3.8-20120326.jar } ....
    

    【讨论】:

      【解决方案3】:

      我刚刚完成了一个项目,我成功地转换并使用了使用 IKVM 0.46.0.1 的 Apache POI 3.9。转换后的 DLL 集支持 2007 年之前和 2007 年之后的 Microsoft Office 格式。

      先决条件:

      下载 POI 3.9 并将所有 JAR 文件复制到一个目录中 下载IKVM(我用的是0.46.0.1版本) 以下命令(在所有 POI JAR 所在的同一目录中的 Windows 7 命令行中运行)对我有用:

      ikvmc -target:library xmlbeans-2.3.0.jar
      ikvmc -target:library stax-api-1.0.1.jar
      
      ikvmc poi-ooxml-schemas-3.9-20121203.jar -target:library -reference:xmlbeans-2.3.0.dll -reference:stax-api-1.0.1.dll 
      
      
      ikvmc -target:library log4j-1.2.13.jar
      ikvmc -target:library commons-logging-1.1.jar
      ikvmc -target:library commons-codec-1.5.jar
      
      ikvmc poi-3.9-20121203.jar -target:library -reference:log4j-1.2.13.dll -reference:commons-logging-1.1.dll -reference:commons-codec-1.5.dll
      
      ikvmc -target:library dom4j-1.6.1.jar
      
      ikvmc poi-ooxml-3.9-20121203.jar -target:library -reference:poi-3.9-20121203.dll -reference:poi-ooxml-schemas-3.9-20121203.dll -reference:dom4j-1.6.1.dll -reference:xmlbeans-2.3.0.dll
      

      希望对你有帮助。

      【讨论】:

      • 我会在我回到我的电脑后尝试
      【解决方案4】:

      弗兰克一次性转换所有罐子的答案为我解决了这个问题。这是我用于 POI 3.10 的完整命令。所有的罐子都需要在同一个目录中。 -out 选项允许您指定输出 dll 的名称,否则它会从第一个 jar 中获取名称。

      ikvmc -target:library -out:poi-3.10.dll xmlbeans-2.3.0.jar stax-api-1.0.1.jar poi-ooxml-schemas-3.10-FINAL-20140208.jar log4j-1.2.13.jar commons-logging-1.1.jar commons-codec-1.5.jar poi-3.10-FINAL-20140208.jar dom4j-1.6.1.jar poi-ooxml-3.10-FINAL-20140208.jar 
      

      【讨论】:

        猜你喜欢
        • 2023-03-14
        • 1970-01-01
        • 2013-07-23
        • 1970-01-01
        • 2011-07-17
        • 1970-01-01
        • 1970-01-01
        • 2014-07-10
        • 2012-11-28
        相关资源
        最近更新 更多