• <tfoot id='SZ2xf'></tfoot>
    <i id='SZ2xf'><tr id='SZ2xf'><dt id='SZ2xf'><q id='SZ2xf'><span id='SZ2xf'><b id='SZ2xf'><form id='SZ2xf'><ins id='SZ2xf'></ins><ul id='SZ2xf'></ul><sub id='SZ2xf'></sub></form><legend id='SZ2xf'></legend><bdo id='SZ2xf'><pre id='SZ2xf'><center id='SZ2xf'></center></pre></bdo></b><th id='SZ2xf'></th></span></q></dt></tr></i><div id='SZ2xf'><tfoot id='SZ2xf'></tfoot><dl id='SZ2xf'><fieldset id='SZ2xf'></fieldset></dl></div>

      <bdo id='SZ2xf'></bdo><ul id='SZ2xf'></ul>
        <legend id='SZ2xf'><style id='SZ2xf'><dir id='SZ2xf'><q id='SZ2xf'></q></dir></style></legend>
      1. <small id='SZ2xf'></small><noframes id='SZ2xf'>

      2. Java - 如何减小第三方 jar 的大小以减小应用程序的大小

        Java - How to reduce the size of third-party jars to reduce the size of your application(Java - 如何减小第三方 jar 的大小以减小应用程序的大小)
        <i id='88Z63'><tr id='88Z63'><dt id='88Z63'><q id='88Z63'><span id='88Z63'><b id='88Z63'><form id='88Z63'><ins id='88Z63'></ins><ul id='88Z63'></ul><sub id='88Z63'></sub></form><legend id='88Z63'></legend><bdo id='88Z63'><pre id='88Z63'><center id='88Z63'></center></pre></bdo></b><th id='88Z63'></th></span></q></dt></tr></i><div id='88Z63'><tfoot id='88Z63'></tfoot><dl id='88Z63'><fieldset id='88Z63'></fieldset></dl></div>
          <tbody id='88Z63'></tbody>

        <tfoot id='88Z63'></tfoot>
          <bdo id='88Z63'></bdo><ul id='88Z63'></ul>

          <legend id='88Z63'><style id='88Z63'><dir id='88Z63'><q id='88Z63'></q></dir></style></legend>

              <small id='88Z63'></small><noframes id='88Z63'>

                  本文介绍了Java - 如何减小第三方 jar 的大小以减小应用程序的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在开发一个 java web 应用程序,其中包括 一个小程序.那个小程序是依赖两个jar文件:

                  I am developing a java web application and that includes an applet. That applet is dependent on two jar files:

                  • JFreeChart(用于在客户端绘制图表) - 1.7 mb(大小jar 文件)
                  • MySqlJdbcConnector(用于存储在客户端捕获的数据,以远程数据库)- .7 mb(大小为jar 文件)
                  • JFreeChart (for plotting graphs at the client side) - 1.7 mb(size of jar file)
                  • MySqlJdbcConnector (for storing data, captured at the client side, to a remote database) - .7 mb (size of jar file)

                  现在,问题是上面的大小两个jar文件.我的总大小小程序 jar (myApplet.jar)2.5mb 其中 2.4 mb 是因为上面的两个jar文件.

                  Now, the problem is the size of above two jar files. The total size of my applet jar (myApplet.jar) is 2.5 mb out of which 2.4 mb is because of the above two jar files.

                  我没有使用所有的类那些jar文件.具体来说,对于jfreechart,我使用的类非常少图书馆.

                  I am not using all the classes in those jar files. Specifically, for jfreechart, I am using a very small number of classes from that library.

                  ===============================问题=======================================

                  ==============================Questions======================================

                  Q1. 为了创建 myApplet.jar 文件,我已经解压缩了两个 jar 文件(jfreechart 和 mySQLJdbcConnector),然后打包了解压缩的版本jar 文件与我的小程序代码的源代码来创建一个单独的 jar 文件(即 myApplet.jar). 这是用您的小程序代码打包第三方 jar 文件的正确方法吗?有什么办法可以优化吗?

                  Q1. For creating myApplet.jar file, what I have done is I have unzipped both of the jar files (jfreechart and mySQLJdbcConnector) and then packed the unzipped version of the jar files with the source code of my applet code to create one single jar file (i.e myApplet.jar). Is it the correct way of packing third party jar files with your applet code? Is there any way by which I can optimize this?

                  Q2. 我试图找到我在我的应用程序中使用的 jfreechart 库的类的依赖项,以便仅将这些依赖项打包到 myApplet.jar.为此,我使用 DependencyAnalyzer 来查找所有类的依赖关系.但后来我发现手动这样做很困难,因为每个类(我在我的应用程序中使用的 jfreechart 类)都有很多依赖项,而且我使用了大约 15 个 jfreechart 类,所以对每个类都这样做会非常困难.那么对此有什么建议吗?

                  Q2. I tried to find the dependencies of the classes of jfreechart library which I am using in my application so as to pack only those dependencies in myApplet.jar. For that purpose, I used DependencyAnalyzer to find the dependencies of all the classes. But later I found it difficult to do so manually because every class (class of jfreechart that I am using in my application) has lot of dependencies and I am using some 15 classes of jfreechart so doing this for every class will be very difficult. So any suggestion on this?

                  Q3.这种情况是开发人员经常遇到的还是我错过了一些东西,因此我必须这样做?

                  Q3. Is this situation very common that developers encounter or I am missing something because of which I have to do this?

                  推荐答案

                  A1:

                  您可以创建一个 ant 脚本或使用 Eclipse 或任何其他 IDE 来自动打包您的小程序.不过你的方法也是对的

                  A1:

                  You can create an ant script or use Eclipse or any other IDE to automatically package your applet. But your way is correct, too

                  我不会手动做这些事情.寻找传递依赖是非常复杂的.也许 darioo 的回答是更好的方法.

                  I wouldn't do these things manually. Finding transitive dependencies is very complex. Maybe darioo's answer is a better way to do this.

                  这确实很常见.一些提示:

                  This is very common indeed. A couple of hints:

                  您始终可以在没有调试信息的情况下重新构建这些第三方库.这应该会稍微减小这些库的大小.

                  You can always re-build those third party libraries without debug information. That should slightly decrease the size of those libraries.

                  另一方面,也许您不应该从您的小程序直接连接到数据库.您可以创建一个 RMI 接口(或类似的接口)来将您的 SQL 和结果数据传输到实际执行您的 SQL 的应用程序服务器.如果您不在安全的 Intranet 中运行,这对您的小程序来说是一个重要的安全方面.

                  On the other hand, maybe you shouldn't have a direct connection from your applet to a database. You could create an RMI interface (or something similar) to transfer your SQL and result data to an application server, which actually executes your SQL. This is an important security aspect for your applet, if you don't run this in a safe intranet.

                  这篇关于Java - 如何减小第三方 jar 的大小以减小应用程序的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Maven JAVA_HOME environment variable is not defined correctly, but it is(Maven JAVA_HOME 环境变量未正确定义,但它是)
                  Java System Environment Variable(Java 系统环境变量)
                  Java -classpath option(Java -classpath 选项)
                  Read environment variable in SpringBoot(在 SpringBoot 中读取环境变量)
                  Tomcat 8 - context.xml use Environment Variable in Datasource(Tomcat 8 - context.xml 在数据源中使用环境变量)
                  Issue with JAVA_HOME(JAVA_HOME 的问题)
                • <legend id='9WfxB'><style id='9WfxB'><dir id='9WfxB'><q id='9WfxB'></q></dir></style></legend>
                    <bdo id='9WfxB'></bdo><ul id='9WfxB'></ul>

                        <tbody id='9WfxB'></tbody>

                        <tfoot id='9WfxB'></tfoot>
                          <i id='9WfxB'><tr id='9WfxB'><dt id='9WfxB'><q id='9WfxB'><span id='9WfxB'><b id='9WfxB'><form id='9WfxB'><ins id='9WfxB'></ins><ul id='9WfxB'></ul><sub id='9WfxB'></sub></form><legend id='9WfxB'></legend><bdo id='9WfxB'><pre id='9WfxB'><center id='9WfxB'></center></pre></bdo></b><th id='9WfxB'></th></span></q></dt></tr></i><div id='9WfxB'><tfoot id='9WfxB'></tfoot><dl id='9WfxB'><fieldset id='9WfxB'></fieldset></dl></div>

                            <small id='9WfxB'></small><noframes id='9WfxB'>