修剪我的 Java 项目

发布于 2024-11-25 05:18:34 字数 336 浏览 1 评论 0原文

我目前正在开发一个使用 jfreechart 库的项目。我目前正在使用该库的 jar 文件,将其添加到我的构建路径中。但是我不需要该库的全部功能。我只想划分出我使用过的代码以及显然依赖的代码的库部分。

我的最终目标是缩小项目的规模。我必须满足一些大小目标,并且使用整个 7 MB jar 库不是一个选项。

我想知道除了手动检查依赖项之外是否还有其他方法可以做到这一点?

理想情况下,我希望将任何建议的方法应用于库的 jar 文件,但如果有一种方便的方法来检测源代码中未使用的代码,我愿意将源代码导入到我的项目中。

如果我的请求是重复的或愚蠢的问题,我深表歉意。

谢谢, 苏迪普托

I am currently working on a project that utilizes the jfreechart library. I am currently using the jar file for this library by adding it in my build path. However I do not need the entire functionality of the library. I would like to carve out only those sections of the library I have used my code and obviously the dependent code.

My ultimate aim is to reduce the size of the project. I have to meet some size targets and using the entire 7 mb jar library is not an option.

I wanted to know if there is a way to do this apart from manually checking for dependencies?

I would ideally like to apply any suggested method to the jar file of the library but if there is a convenient way to detect unused code in the source code I am willing to import the source code into my project.

I apologize if my request is a repeat or a stupid question.

Thanks,
Sudipto

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

神爱温柔 2024-12-02 05:18:34

不幸的是,如果不(可以说)违反 JFreeChart 许可证,您就无法做到这一点。

JFreeChart 根据 Lesser GNU 公共许可证获得许可,该许可证的原则之一是最终用户应该可以自由修改或替换软件中嵌入的许可软件。如果您从 JFreeChart 中挑选类并将它们合并到您的 JAR 中,那么您的用户将很难行使他们的权利来替换嵌入的 JFreeChart 类。这当然违背了 LGPL 的精神。

有关更多详细信息,请参阅 GNU LGPL 和 Java 页面。


如果您想使用 JFreeChart 执行此类操作,则需要获得版权所有者的许可。如果您的主管确实热衷于缩小下载大小,向 JFreeChart 项目捐赠大量现金可能会帮助他们接受他的想法。 (免责声明 - 我与该项目没有任何关系。)

Unfortunately, you can't do this without (arguably) violating the JFreeChart license.

JFreeChart is licensed under the Lesser GNU Public License, and one of the tenets of that license is that the end-user should be free to modify or replace the licensed software embedded in your software. If you cherry-pick classes from JFreeChart and incorporate them into your JAR, you make it difficult for your users to exercise their right to replace the embedded JFreeChart classes. This is certainly against the spirit of the LGPL.

For more details, refer to the GNU LGPL and Java page.


If you want to do this kind of thing with JFreeChart, you will need to get permission from the copyright holder. If your supervisor is really keen to keep the download size down, a large cash donation to the JFreeChart project might help them come around to his way of thinking. (Disclaimer - I have no connection whatsoever to the project.)

浅黛梨妆こ 2024-12-02 05:18:34

这确实很难确定,因为应用程序的执行路径每次运行都可能不同。但是,有 仪器 界面,可以显示JVM当前加载的所有类。这应该会让您知道要保留哪些课程。只要您运行了应用程序的所有可能结果。

一般来说,这当然是一个坏主意,但既然你问了......

This can indeed be hard to determine because execution paths of an application can differ per run. However there is the Instrumentation interface which can show you all the classes currently loaded by the JVM. That should give you an idea which classes to keep. As long as you have run all the possible outcomes of the application.

Generally speaking, this is of course a bad idea, but since you've asked...

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