2 Replies Latest reply: Mar 31, 2013 12:39 PM by 1000182 RSS

    To get a single .jar file with NetBeans?

    1000182
      When I click on "Clean and Build" NetBeans generates a .jar file and inside the folder "dist" it add a directory called "lib" with all the java libraries used to implement the program. I would like to achieve with this IDE an unique .jar file that includes everything you need such as Eclipse does by default. Is it possible?

      Thanks
        • 1. Re: To get a single .jar file with NetBeans?
          gimbal2
          997179 wrote:
          When I click on "Clean and Build" NetBeans generates a .jar file and inside the folder "dist" it add a directory called "lib" with all the java libraries used to implement the program. I would like to achieve with this IDE an unique .jar file that includes everything you need such as Eclipse does by default. Is it possible?
          You're mistaken, Eclipse does not produce such a jar by default. You may be using some specific plugin / project type that does it.

          What you are looking for is a "onejar" type of solution, of which there are plenty only a google away. Beware when using such a thing, it may be that you're breaking the license of one or more libraries when you do this.
          • 2. Re: To get a single .jar file with NetBeans?
            1000182
            Thanks for your help. I never installed plugin on Eclipse, I can't do that! However I would like to merge jar files into single file with NetBeans. I am reading this procedure but it is too hard for me, I don't understand very well what I have to do.

            http://wiki.netbeans.org/PackagingADistributableJavaApp


            OneJAR
            Installing OneJAR
            Download one-jar-sdk-096.jar.zip, unpack it somewhere. For version 0.97, download one-jar-ant-task-0.97.jar, rename it to one-jar-ant-task-0.97.zip, and unzip that.
            Create a directory BundlingTools next to the HelloWorld directory.
            Move the file one-jar-ant-task-0.96.jar from the one-jar-sdk directory into BundlingTools.
            Move the file one-jar-ant-task.xml from the one-jar-sdk directory (or from one-jar-ant-task-0.97.zip) into HelloWorld.
            Change the first line in one-jar-ant-task.xml to point to your value="../BundlingTools" directory

            For example I don't know how I must edit one-jar-ant-task.xml. I have:

            NomeProgetto:
            build
            BundlingTools
            dist
            nbproject
            src
            build.xml
            manifest.mf
            one-jar-ant-task.xml

            Into BunblingTools I have one-jar-ant-task-0.97.jar. I edited .xml file in this way:

            <?xml version="1.0"?>
            <project>
            <!-- The following property is expected to be overridden by caller -->
            <property name="one-jar.dist.dir" value="BundlingTools"/>
            <property name="one-jar.version" value="0.97"/>
            <property name="one-jar.ant.jar" value="${one-jar.dist.dir}/one-jar-ant-task-${one-jar.version}.jar"/>
            <taskdef name="one-jar" classname="com.simontuffs.onejar.ant.OneJarTask"
            classpath="${one-jar.ant.jar}" onerror="report"/>

            </project>

            but It doesn't work!