我想在.NET中使用Flying Saucer Java API,所以我尝试使用IKVM转换Flying Saucer库:
ikvmc core-renderer.jar
出于某种原因,IKVMC给了我一个exe core-renderer.exe
所以我将其重命名为core-renderer.dll
,添加到我的程序集中并被黑客攻击
using java.io;
using java.lang;
using com.lowagie.text;
using org.xhtmlrenderer.pdf;
namespace flying_saucer
{
class FlyingSaucerApp
{
static void Main(string[] args)
{
// This works
DocumentException dummy = new DocumentException();
ITextRenderer renderer = new ITextRenderer();
// For some reason, this raises NoClassDefFoundError
renderer.setDocument(File("hello.xhtml").toURI().toURL().toString());
}
}
}
出于某种原因,它正在提供java.lang.NoClassDefFoundError: com.lowagie.text.DocumentException
。我意识到DocumentException
可能会引发ITextRender()
,但我已经包含了com.lowagie.text
,有什么想法吗?
答案 0 :(得分:5)
事实证明,对于这种特殊情况,我需要渲染Flying Saucer和iText(Flying Saucer的依赖)并让Flying Saucer程序集参考其依赖:
ikvmc -target:library itext.jar
ikvmc -target:library -reference:itext.dll core-renderer.jar
(对于新手:如果您没有阅读任何文档而只是尝试命令,您还需要确保IKVMC附带的DLL文件也存在 - 最简单的方法是转储所有IKVMC您的iText JAR文件旁边的文件)
答案 1 :(得分:2)
确保您已将IKVM.AWT.WinForms.dll
,IKVM.OpenJDK.ClassLibrary.dll
,IKVM.Runtime.dll
和IKVM.Runtime.JNI.dll
程序集包含在项目中。另外,为避免生成可执行文件然后重命名,您可以在编译时指定-target:library
开关。