使用 IKVM 转换 JAR(飞碟 - xhtmlrenderer)
我想在.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
,有什么想法吗?
I wanted to use the Flying Saucer Java API in .NET so I tried to use IKVM to convert the Flying Saucer library:
ikvmc core-renderer.jar
For some reason, IKVMC gave me an exe core-renderer.exe
so I renamed it to core-renderer.dll
, added to my assemblies and hacked away
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());
}
}
}
For some reason, it is giving java.lang.NoClassDefFoundError: com.lowagie.text.DocumentException
. I realized DocumentException
is something ITextRender()
may throw, but I've already included com.lowagie.text
, any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实证明,对于这种特殊情况,我需要渲染 Flying Saucer 和 iText(Flying Saucer 的依赖项),并让 Flying Saucer 程序集引用其依赖项:(
对于新手:如果您没有阅读任何文档并且是只是尝试命令,您还需要确保 IKVMC 附带的 DLL 文件也存在 - 最简单的方法是将所有 IKVMC 文件转储到 iText JAR 文件旁边)
It turned out that for this particular situation, I needed to render both Flying Saucer and iText (a dependency of Flying Saucer) and have the Flying Saucer assembly reference to its dependency:
(For newbies: If you didn't read any documentation and are just trying the commands, you also need to make sure the DLL files accompanying IKVMC is also present -- the easiest way to do this is to dump all the IKVMC files beside your iText JAR files)
确保您已包含
IKVM.AWT.WinForms.dll
、IKVM.OpenJDK.ClassLibrary.dll
、IKVM.Runtime.dll
和 < code>IKVM.Runtime.JNI.dll 程序集到您的项目中。另外,为了避免生成可执行文件然后重命名它,您可以在编译时指定-target:library
开关。Make sure you've included
IKVM.AWT.WinForms.dll
,IKVM.OpenJDK.ClassLibrary.dll
,IKVM.Runtime.dll
andIKVM.Runtime.JNI.dll
assemblies into your project. Also to avoid generating an executable and then renaming it you could specify the-target:library
switch when compiling.