【问题标题】:Export Jar File in NetBeans在 NetBeans 中导出 Jar 文件
【发布时间】:2012-05-12 07:31:06
【问题描述】:

我正在寻找一种在 Netbeans 中导出 .jar 文件的方法。我知道当我清理/构建它时,它会自动将所有内容放在 dist 目录中的 .war 文件中。但是,在 Eclipse 中,您可以选择导出 -> 导出 -> Java -> JAR 文件并单击下一步,然后仅选择要导出的资源并选择要将 .jar 文件导出到的位置。 Netbeans 中是否有与此等价的功能?

【问题讨论】:

    标签: eclipse netbeans jar export


    【解决方案1】:

    您可以在 Netbeans 中启用“编译后构建 JAR”属性

    文件 > 项目属性 > 构建 > 打包

    【讨论】:

    • 我在文件 -> 项目属性 -> 构建 -> 打包下看不到“编译后构建 JAR”属性
    【解决方案2】:

    我最终只是以通常的方式构建项目,在 dist 文件夹中获取 .war 文件。
    然后我使用了一个名为 IZArc:http://www.izarc.org/ 的 zip 程序来打开 .war 并只取出构建 .jar 所需的内容。然后我再次使用 IZArc 创建 .jar 文件。
    如果有人知道更简单的方法(最好是通过 Netbeans 本身),请告诉我。

    【讨论】:

      【解决方案3】:

      如果您知道如何编写 Ant 文件,请编辑 build.xml 并添加 -post-dist 目标。然后在创建war文件时也会创建jar文件。比如:

      <target name="-post-dist" description="Create jar file.">
          <!-- Copy your files to a temp directory if necessary. -->
          <copy ...>
             ...
          </copy>
      
          <!-- 'basedir' should be the directory from which to jar the files -->
          <jar destfile="${dist.dir}/app.jar" basedir="${build.dir}/myjarfiles"/>
      </target>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-08-14
        • 1970-01-01
        • 1970-01-01
        • 2020-04-03
        • 2019-01-06
        • 2016-06-09
        相关资源
        最近更新 更多