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

  • <small id='0RBci'></small><noframes id='0RBci'>

      1. 创建 JAR 文件而不包含外部依赖项

        Create JAR file without including external dependencies(创建 JAR 文件而不包含外部依赖项)

          <small id='cOu1D'></small><noframes id='cOu1D'>

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

                  本文介绍了创建 JAR 文件而不包含外部依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  是否可以创建需要外部依赖项的 JAR 文件而不在 JAR 文件中包含这些依赖项?

                  Is it possible to create a JAR file that requires external dependencies without including those dependencies in the JAR file?

                  我的 google-fu 没有给我答案;我发现的所有内容都显示了如何将它们包含在 JAR 文件中,而不是在清单文件中放入什么来表示我没有得到它们,请查看用户的类路径".我会假设依赖项已在用户的类路径上正确安装和配置.

                  My google-fu has failed to give me an answer; everything that I have found shows how to include them in the JAR file, but not what to put in the manifest file to say "I haven't got them, look in the user's classpath". I would assume that the dependencies are properly installed and configured on the user's classpath.

                  就我而言,我的依赖项是 Apache Commons CLI 和 Math.

                  In my case, my dependencies are Apache Commons CLI and Math.

                  在我的 JAR 文件中,我有 Main.class.

                  Inside my JAR file, I have Main.class.

                  我的清单文件如下所示:

                  My manifest file looks like:

                  Manifest-Version: 1.0
                  Created-By: 1.6.0 (Sun Microsystems Inc.)
                  Main-Class: Main
                  

                  我的 CLASSPATH 看起来像

                  My CLASSPATH looks like

                  .;C:Program FilesJavajre1.6.0_06libextQTJava.zip;C:java_libcommons-cli-1.2.jar;C:java_libcommons-math-2.0commons-math-2.0.jar
                  

                  如果我在 /lib 的 JAR 中包含依赖项并添加行 Class-Path: lib/commons-math-2.0.jar lib/commons-cli-1.2.jar 到清单,然后它就可以工作了.

                  If I include the dependencies in the JAR in /lib and add the line Class-Path: lib/commons-math-2.0.jar lib/commons-cli-1.2.jar to the manifest, then it does work.

                  我已尝试将 Class-Path: commons-math-2.0.jar commons-cli-1.2.jar 添加到清单中,但不包括 JAR 中的文件,只是为了看看这是否可行,但它没有.

                  I've tried adding Class-Path: commons-math-2.0.jar commons-cli-1.2.jar to the manifest without including the files in the JAR just to see if that would work, but it didn't.

                  推荐答案

                  使用META-INF/MANIFEST.MF 中的 "nofollow noreferrer">Class-Path 条目,以告知在哪里查找与您的 JAR 相关的依赖项.例如:

                  Use the Class-Path entry in the META-INF/MANIFEST.MF to tell where to look for dependencies relatively to your JAR. For example:

                  Class-Path: servlet.jar ../foo/bar.jar acme/beans.jar
                  

                  这篇关于创建 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 的问题)
                  <tfoot id='orW2q'></tfoot>
                  <i id='orW2q'><tr id='orW2q'><dt id='orW2q'><q id='orW2q'><span id='orW2q'><b id='orW2q'><form id='orW2q'><ins id='orW2q'></ins><ul id='orW2q'></ul><sub id='orW2q'></sub></form><legend id='orW2q'></legend><bdo id='orW2q'><pre id='orW2q'><center id='orW2q'></center></pre></bdo></b><th id='orW2q'></th></span></q></dt></tr></i><div id='orW2q'><tfoot id='orW2q'></tfoot><dl id='orW2q'><fieldset id='orW2q'></fieldset></dl></div>

                  • <bdo id='orW2q'></bdo><ul id='orW2q'></ul>

                        <tbody id='orW2q'></tbody>

                      1. <legend id='orW2q'><style id='orW2q'><dir id='orW2q'><q id='orW2q'></q></dir></style></legend>

                            <small id='orW2q'></small><noframes id='orW2q'>