简体   繁体   中英

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. 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.

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.

"Class Not Found Exceptions" related to the external Apache-Tika Library.

Multiple Jars can be listed in the archive attribute of the applet element. See W3C on the archive attribute ..

This attribute specifies a comma-separated list of URIs for archives containing classes and other resources that will be "preloaded".

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 the tika-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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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