Netbeans Export to Jar,包括所有库文件 [英] Netbeans Export to Jar, include all library files

查看:147
本文介绍了Netbeans Export to Jar,包括所有库文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真正需要的是与Eclipse和Netbeans相当:

What I really need is an equivalent of this from Eclipse with Netbeans:

我想要将所需的库提取到生成的JAR 所以我可以分发它,而不需要在任何地方都包含lib文件夹。

I want to Extract required libraries into generated JAR so I can distribute it without the need of including the lib folder everywhere it goes.

这是原始问题。

我正在尝试用 Netbeans 构建一个jar,它将打包所有的里面的库文件。通过选择Export,我听说Eclipse是可能的。使用Netbeans,如果我清理并构建它将在dist文件夹中创建一个可执行jar,但它所依赖的所有库都在一个名为lib的文件夹中。我需要一切都在一个jar文件中。我认为它与build.xml文件有关。这是我的说法。我在这里弄错了什么?

I'm trying to build a jar out of Netbeans that will package all the library files inside it. I've heard it's possible with Eclipse by choosing Export. With Netbeans, if I "Clean and Build" it will create an executable jar in the dist folder, but all the libraries it depends on are in a folder called lib. I need it all to be in one jar file. I'm thinking it has to do with the build.xml file. Here's what mine says. What am I getting wrong here?

感谢您的帮助。

<?xml version="1.0" encoding="UTF-8"?>
<project name="BONotifier" default="default" basedir=".">
  <description>Builds, tests, and runs the project BONotifier.</description>
  <import file="nbproject/build-impl.xml"/>
  <target name="-post-jar">
    <jar jarfile="dist/Combined-dist.jar">
      <zipfileset src="${dist.jar}" excludes="META-INF/*" />
      <zipfileset src="lib/commons-io-1.4.jar" excludes="META-INF/*" />
      <manifest>
        <attribute name="Main-Class" value="controller.MainController"/>
      </manifest>
    </jar>
  </target>
</project>

更新:上面的代码位于build.xml中。以下是build-impl.xml。我猜这意味着build.xml在build-impl.xml期间运行。

Update: The code above is in build.xml. The following is in build-impl.xml. I'm guessing this means that build.xml is run during build-impl.xml.

<target name="-pre-init">
    <!-- Empty placeholder for easier customization. -->
    <!-- You can override this target in the ../build.xml file. -->
</target>

注意我从这里得到了这个论坛

Note I got this from this forum.

推荐答案

我更喜欢这个解决方案,因为没有任何东西可以下载,所有都基于Ant构建(~20行)。这样就没有额外的依赖性了。如果你有几分钟的时间,你也可以了解Ant。

I prefer this solution since there is nothing to download, all based on Ant build (~20 lines). That way there is no additional dependency to bother with. If you have a couple of minutes, you can learn about Ant too.

看来原始文章的链接被破坏了(感谢Oracle)。这是另一个链接

It seems like the link to the original Article is broken (thanks Oracle). Here is another link.

原始文章也可从Oracle获得链接

The original article is also available from Oracle link.

这篇关于Netbeans Export to Jar,包括所有库文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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