使用 IKVM 转换 JAR(飞碟 - xhtmlrenderer)

发布于 2024-09-03 07:58:55 字数 1150 浏览 5 评论 0原文

我想在.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。我意识到 DocumentExceptionITextRender() 可能会抛出的问题,但我已经包含了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

生生漫 2024-09-10 07:58:55

事实证明,对于这种特殊情况,我需要渲染 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 文件旁边)

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:

ikvmc -target:library itext.jar
ikvmc -target:library -reference:itext.dll core-renderer.jar

(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)

迷爱 2024-09-10 07:58:55

确保您已包含 IKVM.AWT.WinForms.dllIKVM.OpenJDK.ClassLibrary.dllIKVM.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 and IKVM.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文