带有 java Applet 的嵌套 Jar
首先,我已经解决了这里有关包含小程序的 jar 文件的所有问题。但即便如此,我还是遇到了这个“巨大”的问题。
我正在使用 java 和 Apache-Tika 库(有 4 个 jar,总共大小 40 mbs)开发一个应用程序。该应用程序需要计算上传文档(doc、docx、odf、pdf 等)中的字数。该小程序在 Netbeans 6.5 或 Eclipse IDE 中运行得很好,我正在并行使用它们进行开发。但是当我尝试将其部署到浏览器时,出现了问题。
问题
初始页面加载得很好。但是当我给出文档的路径并单击“确定”(或“计数”)时,我收到大量错误消息。 这些都是与外部 Apache-Tika 库相关的“未找到类异常”。我认为我已经正确完成了库的所有包含,否则它不会在小程序查看器中运行。
至于 HTML,我创建了整个字计数器应用程序的 jar,以及库(4 个 Apache-Tika Jars)和所有其他必要的文件,并将该 jar 包含在相应的标签中。 我需要在 HTML 文件中提及有关嵌套 jar 库的任何内容吗?嵌套 jar 是否有限制? 任何形式的帮助将受到高度赞赏。 谢谢你们提前了解了人们。
First of all, I have gone through all the questions here regarding the inclusion of jar files for an applet. But even then, I have this 'Huge' Problem.
I am developing an application with java and the Apache-Tika Library (with 4 jars, totaling the size of 40 mbs). The application needs to count the number of words in an uploaded document (doc, docx, odf, pdf and a bunch of other). The applet runs pretty well from Netbeans 6.5 or Eclipse IDE which I am using side by side for the development. But when I try to Deploy it to a browser, there's a problem.
Problem
The initial page loads pretty good. But as I give the path of the document and Click Ok (or Count), I get loads of error messages.
Those are all "Class Not Found Exceptions" related to the external Apache-Tika Library. I think I have done all the inclusion of the library correctly as other wise it wouldn't run in the applet viewer.
As for the HTML, I have created a jar of the entire Word-Counter Application, along with the library(4 Apache-Tika Jars) and all other necessary files, and included the jar in the tag accordingly.
Do I need to mention anything on the HTML file about the nested jar library, is there a limitation regarding a nested jar?
Any Kind of help would be Highly Appreciated.
Thank You learned Folks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
听起来您可能以错误的方式处理这个问题。您确实不应该通过浏览器 Applet 进行任何文档分析。而是将文档上传到服务器并在那里进行分析。对于任何将使用您正在创建的应用程序的人来说,要求用户下载 40MB 的 jars 作为最终解决方案可能是不可接受的。
It sounds like you may be approaching this the wrong way. You really shouldn't be doing any document analysis from a browser Applet. Instead upload the document to a server and analyze it there. Requiring users to download 40MBs of jars is probably unacceptable as an end solution to anyone who will use the application you are creating.
可以在
applet
元素的archive
属性中列出多个 Jars。请参阅W3C 关于存档属性。Multiple Jars can be listed in the
archive
attribute of theapplet
element. See W3C on the archive attribute..为什么不将所有依赖项 jar 中的所有类包含在 applet jar 中呢?
Tika 包含一个可以完成此操作的 jar -
tika-app.jar
。您可以运行tika-app
而无需任何额外的 jar 或依赖项,它包含所需的一切。如果您查看 tika-app pom,您将看到构建这样一个 jar 的适当 Maven 魔法。否则,要手动执行此操作,只需将所有 jar 解压到一个目录中,然后再次重新打包即可。
Why not just include all the classes from all the dependency jars inside your applet jar?
Tika includes a single jar that does that very thing -
tika-app.jar
. You can run thetika-app
without needing any extra jars or dependencies, it includes everything that's required.If you look at the tika-app pom, you'll see the appropriate maven magic to have such a jar built. Otherwise, to do it by hand, simply unpack all your jars into a single directory, then re-jar that up again.