This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 167067

Summary: Java Store - Combining multiple JAR files in "dist" directory into one JAR for Publication on Java Store
Product: projects Reporter: stephensr <stephensr>
Component: LibrariesAssignee: Jesse Glick <jglick>
Status: RESOLVED DUPLICATE    
Severity: blocker    
Priority: P2    
Version: 6.x   
Hardware: Macintosh   
OS: All   
URL: http://java.sun.com/warehouse/reference/release_notes/index.jsp
Issue Type: ENHANCEMENT Exception Reporter:

Description stephensr 2009-06-14 21:01:20 UTC
Summary
----------------
We are trying to publish our application (which contains application libraries) on the Java Store. Since our Swing app which was built in Netbeans contains 
libraries, we need to combine our "app.jar" and the "library.jar" files into a single jar file before we publish on Java Warehouse/Store...........the Java 
Warehouse documented process for combining JAR files does not appear to work.

Would it be possible to add a "package for Java Warehouse" button in Netbeans to streamline this process? ***** Until then please let us know how to make 
this manual process work***** 

thank you

Problem
---------------
The following link provided on the Java Warehouse help menu shows developers how to combine Netbeans application jar's and libraries in the "dist" 
directory into ***One Single JAR file for Publication/Distribution on Java Warehouse***..............this does not appear to generate a valid MANIFEST.MF file 
and thus the app will not launch from the single jar file.

http://java.sun.com/warehouse/reference/release_notes/index.jsp

The problem is that this process does not appear to work properly.

================== Java Warehouse Process ==================================
http://java.sun.com/warehouse/reference/release_notes/index.jsp

Issue: Applications composed of several JAR files (libs) cannot be uploaded.

Description: There is no way to upload applications composed of several JAR files (libs). They must be assembled into a single JAR file.

Workaround: Use the following procedures to combine multiple JAR files into a single file:

================== Java Warehouse Process ==================================


Problem Example - buld.xml file from NetBeans
---------------------------------------------------------------------------

Here are the additions to the build.xml file per the Java Warehouse instructions

<target name="package-for-store"> 
    <echo message="packaging up "/> 
    <!-- the name of your app, minus the .jar extension. should not have spaces. 
    or use the default (the name of your app) 
    <property name="jar.name" value="MyApp"/> 
    --> 
    <property name="jar.name" value="MyProductionApp"/>
    <!-- the main class in your app. you *Must* edit this--> 
    <property name="main.classname" value="com.thinkingtechnologies.ttsmedia.ui.MyProductionApp"/>
    <!-- don't edit below this line --> 
    <mkdir dir="final"/> 
    <jar destfile="final/temp_final.jar" filesetmanifest="skip"> 
        <zipgroupfileset dir="dist" includes="*.jar"/> 
        <zipgroupfileset dir="dist/lib" includes="*.jar"/> 
        <manifest> 
            <attribute name="Main-Class" value=""/>
        </manifest> 
    </jar> 
    <zip destfile="final/.jar"> 
        <zipfileset src="final/temp_final.jar" 
        excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/> 
    </zip> 
</target>



Good Example - MANIFEST.MF file in "dist" directory  from NetBeans default build process
-----------------------------------------------------------------------------------------------------------------------
-------
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 1.5.0_16-133 (Apple Inc.)
Main-Class: com.thinkingtechnologies.ttsmedia.ui.MyProductionApp
Class-Path: lib/AbsoluteLayout.jar lib/swing-layout-1.0.3.jar lib/bean
 sbinding-1.2.1.jar
X-COMMENT: Main-Class will be added automatically by build


These are the corresponding directory contents in the NetBeans build output "dist" distribution directory. Note that double clicking on (or from the 
command-line running java -jar MyProductionApp.jar) successfully launches the application


drwxr-xr-x  3 developer-3  developer-3    102 Jun 14 04:34 META-INF
-rw-r--r--  1 developer-3  developer-3   1449 Jun 14 04:30 README.TXT
-rw-r--r--  1 developer-3  developer-3  74702 Jun 14 04:30 MyProductionApp.jar
drwxr-xr-x  3 developer-3  developer-3    102 Jun 14 04:34 com
drwxr-xr-x  5 developer-3  developer-3    170 Jun 14 04:30 lib

Problem Example - MANIFEST.MF file in "final" using Java Warehouse  build process for NetBeans
-----------------------------------------------------------------------------------------------------------------------
-----------------
Here are the corresponding MANIFEST.MF file contents and the contents of the "final" directory per the output of the Java Warehouse build process using 
"ant" to combine the library and app jar files into one jar file..................bottom line is that this process does not appear to create a valid MANIFEST.MF file 
whereas the default build process in Netbeans does.

MANIFEST.MF file
----------------------------
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 1.5.0_16-133 (Apple Inc.)
main.classname: 

"final" directory contents
----------------------------------------
-rw-r--r--  1 developer-3  developer-3  371848 Jun 14 14:34 temp_final.jar

Output from running "ant" on the modified NetBeans build.xml file
--------------------------------------------------------------------------------------------
lab5:MyProductionApp developer-3$ ant package-for-store
Buildfile: build.xml

package-for-store:
     [echo] packaging up 
    [mkdir] Created dir: /Users/developer-3/jdevhome/mywork/nb/1_Java_Store_Workspace/merge_for_store_candidate-1/MyProductionApp/final
      [jar] Building jar: /Users/developer-3/jdevhome/mywork/nb/1_Java_Store_Workspace/merge_for_store_candidate-
1/MyProductionApp/final/temp_final.jar
      [zip] Building zip: /Users/developer-3/jdevhome/mywork/nb/1_Java_Store_Workspace/merge_for_store_candidate-1/MyProductionApp/final/.jar

BUILD SUCCESSFUL
Total time: 0 seconds
lab5:MyProductionApp developer-3$
Comment 1 Jesse Glick 2009-07-06 18:36:51 UTC
Either the release notes for Java Store are incorrect, or something is wrong with the FX build-impl.xml.
Comment 2 Adam Sotona 2009-07-07 16:14:36 UTC
I don't see any relation with JavaFX.

BTW JavaFX would not allow such Manifest manipulation, the binaries must be always produced by Javafxpackager tool and
main class does not correspond to the user main JavaFX script.
Comment 3 Jesse Glick 2009-07-07 21:25:11 UTC
I think you just did not follow the instructions from the release notes carefully enough. Anyway those instructions are
too complicated and not advisable; try just this in your build.xml:

    <target name="-post-jar">
        <mkdir dir="${dist.dir}/merged"/>
        <jar destfile="${dist.dir}/merged/${ant.project.name}.jar">
            <zipgroupfileset dir="dist" includes="**/*.jar" excludes="merged/"/>
            <manifest>
                <attribute name="Main-Class" value="${main.class}"/>
            </manifest>
        </jar>
    </target>

*** This issue has been marked as a duplicate of 25376 ***
Comment 4 Jesse Glick 2009-07-07 21:29:10 UTC
I sent a note to webmasters about the release notes for the Java Store. Perhaps it will be considered, I don't know.