使用IKVM.Net将Apache POI .jar转换为.dll

时间:2012-12-01 11:28:51

标签: java .net dll apache-poi ikvm

我正在尝试将Apache poi .jar转换为.dll。我用下面的脚本进行转换。但是之后我收到很多警告和错误 无效选项-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的正确方法吗?如果没有,那么正确的脚本是什么。

4 个答案:

答案 0 :(得分:2)

ikvmc compiler is documented-resource选项如下:

  

-resource:name = path包含名为name

的Java资源的路径

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

an example of the ant wrapper around ikvmcresource选项的使用示例证实了这种怀疑:

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

由于ikvmc是一个java-bytecode-to-.net-中间语言编译器,因此它了解如何读取jar文件。因此,您应该只将ikvmc指向原始jar文件,而不是尝试将(先前生成的)DLL包含在编译周期中。

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

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

答案 1 :(得分:1)

您需要将-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 } ....

答案 2 :(得分:1)

我刚刚完成了一个项目,我已成功转换并使用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

希望它有所帮助。

答案 3 :(得分:0)

弗兰克一次性转换所有罐子的答案为我解决了这个问题。这是我用于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 
相关问题