What I really need is an equivalent of this from Eclipse with Netbeans:
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.
Here's the original question.
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?
Thanks for the help.
<?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>
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.
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.
It seems like the link to the original Article is broken (thanks Oracle). Here is another link.
The original article is also available from Oracle link.