简体   繁体   English

Java Applet的嵌套罐

[英]Nested Jar with java Applet

First of all, I have gone through all the questions here regarding the inclusion of jar files for an applet. 首先,我在这里讨论了有关为applet包含jar文件的所有问题。 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). 我正在使用Java和Apache-Tika库(带有4个jar,总计40 mbs)开发一个应用程序。 The application needs to count the number of words in an uploaded document (doc, docx, odf, pdf and a bunch of other). 应用程序需要计算上载文档(doc,docx,odf,pdf和其他文件)中的单词数。 The applet runs pretty well from Netbeans 6.5 or Eclipse IDE which I am using side by side for the development. 该小程序在Netbeans 6.5或Eclipse IDE上运行得非常好,我正在并排使用它进行开发。 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. 这些都是与外部Apache-Tika库有关的“ 找不到类异常 ”。 I think I have done all the inclusion of the library correctly as other wise it wouldn't run in the applet viewer. 我认为我正确地完成了所有库的包含,否则将无法在applet查看器中运行。

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. 至于HTML,我创建了一个包含整个Word-Counter应用程序的jar,以及该库(4个Apache-Tika Jars)和所有其他必要的文件,并将该jar相应地包含在标记中。 Do I need to mention anything on the HTML file about the nested jar library, is there a limitation regarding a nested jar? 我是否需要在HTML文件中提及有关嵌套jar库的任何内容,关于嵌套jar是否有限制? Any Kind of help would be Highly Appreciated. 任何帮助都将受到高度赞赏。 Thank You learned Folks in advance. 谢谢你提前学会了民间。

It sounds like you may be approaching this the wrong way. 听起来您可能采用了错误的方法。 You really shouldn't be doing any document analysis from a browser Applet. 您实际上不应该从浏览器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. 作为最终解决方案,要求用户下载40MB的jars对于使用您正在创建的应用程序的任何人来说都是不可接受的。

"Class Not Found Exceptions" related to the external Apache-Tika Library. 与外部Apache-Tika库有关的“找不到类异常”

Multiple Jars can be listed in the archive attribute of the applet element. 可以在applet元素的archive属性中列出多个Jar。 See W3C on the archive attribute .. 有关存档属性,请参阅W3C

This attribute specifies a comma-separated list of URIs for archives containing classes and other resources that will be "preloaded". 此属性为包含要“预加载”的类和其他资源的档案指定URI的逗号分隔列表。

Why not just include all the classes from all the dependency jars inside your applet jar? 为什么不将所有依赖项jar中的所有类都包含在applet jar中?

Tika includes a single jar that does that very thing - tika-app.jar . Tika包含一个可以完成此任务的jar- tika-app.jar You can run the tika-app without needing any extra jars or dependencies, it includes everything that's required. 您可以运行tika-app而无需任何额外的jar或依赖项,它包含了所需的一切。

If you look at the tika-app pom, you'll see the appropriate maven magic to have such a jar built. 如果您查看tika-app pom,您将看到合适的Maven魔术来制作这样的罐子。 Otherwise, to do it by hand, simply unpack all your jars into a single directory, then re-jar that up again. 否则,要手动进行操作,只需将所有jar文件解压缩到一个目录中,然后再次将其重新打包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM