在 Netbeans 8.0.2 和 Java 8 中使用 Apache Tika 1.9 会产生巨大的可执行文件.怎么做才能缩小尺寸? [英] Using Apache Tika 1.9 in Netbeans 8.0.2 and Java 8 produces HUGE executable. What to do to reduce size?

查看:23
本文介绍了在 Netbeans 8.0.2 和 Java 8 中使用 Apache Tika 1.9 会产生巨大的可执行文件.怎么做才能缩小尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用外部库方面运气不佳,所以我只是在任何使用实用程序的项目中包含了实用程序的源代码.

I haven't had much luck with external libraries, so I've just included the source for utilities in any project that uses utilities.

现在我有一个需要 Apache Tika 的项目,所以我必须有一个类似这样的库设置:

Now I have a project that requires Apache Tika, so I have to have a library setup something like this:

但是要从 Netbeans 外部运行程序,我显然(根据 dist 文件夹中的 readme.txt)需要压缩 .jarlib 文件夹,解压缩该压缩文件,提取内容,然后从提取到的任何位置运行.

But to run the program from outside Netbeans, I apparently (per readme.txt in dist folder) need to zip the .jar and lib folder, unzip that zipped file, extract the contents, and run from wherever it's extracted to.

但 Tika 库是 45MB.

But the Tika lib is 45MB.

我只使用了 tika-app-1.9.jar 库文件中的 5 个对象:

I only use 5 objects from the tika-app-1.9.jar library file:

import org.apache.tika.exception.TikaException;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.mime.MimeTypeException;
import org.apache.tika.parser.AutoDetectParser;
import org.apache.tika.sax.BodyContentHandler;

如何将一小部分 Tika 对象制作成一个比 45MB 小很多的库?

How do I make a tiny subset of Tika objects into a library that will be a lot smaller than 45MB?

还是我错过了我应该做的重点?

Or am I missing the point of what I SHOULD do?

推荐答案

你应该只包含 tika-coretika-parsers 组件,这两个文件应该是不超过 1.2MB.

You should only include the tika-core and tika-parsers components, these two files should be no more than 1.2MB.

tika-app jar 在主页上是这样描述的:

The tika-app jar is described on the home page as this:

Tika 应用程序. 将上述组件和所有外部解析器库组合成一个带有 GUI 和命令行界面的可运行 jar.

Tika application. Combines the above components and all the external parser libraries into a single runnable jar with a GUI and a command line interface.

所以它有很多你的应用不需要的额外东西.

So it has a lot of extra things, which your app does not need.

这篇关于在 Netbeans 8.0.2 和 Java 8 中使用 Apache Tika 1.9 会产生巨大的可执行文件.怎么做才能缩小尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆