Bug 82507 Jar creation wizard omits directory entries
Below is email from the customer working on WSAD. I have recreated this behaviour on Eclipse 2.1.1 and 3.0 on Windows 2000 I have viewed the jar files in hex and validated that the Java jar command actually puts additional entries in the .jar compared to Eclipse/WSAD. Both the customer and I believe the Java JAR spec does not address this issue. That is why I have marked it as an enhancement. Customer would like an option to control the creation of directory entries. Here is a more detailed problem description Unzip the attached file somewhere (such as C:\junk). (See attached file: images.jar) Then: C:\junk>jar cvf images1.jar images or C:\junk>jar cvf images2.jar images/ They give the same results, as shown by: C:\junk>jar tvf images1.jar or C:\junk>jar tvf images2.jar 0 Mon Jan 10 09:30:36 CST 2005 META-INF/ 71 Mon Jan 10 09:30:36 CST 2005 META-INF/MANIFEST.MF 0 Mon Jan 10 09:29:58 CST 2005 images/ 144 Tue Jun 22 14:45:42 CDT 2004 images/blank.png 251 Tue Jun 22 14:45:42 CDT 2004 images/file.png 229 Tue Jun 22 14:45:42 CDT 2004 images/foldericon.png 148 Tue Jun 22 14:45:42 CDT 2004 images/I.png 232 Tue Jun 22 14:45:42 CDT 2004 images/openfoldericon.png 152 Tue Jun 22 14:45:42 CDT 2004 images/T.png Note the existence of the directory entries and the order of the files (the OS-native order for Windoze). Now try: C:\junk>jar cvf images3.jar images/* and dump the results: C:\junk>jar tvf images3.jar 0 Mon Jan 10 09:31:14 CST 2005 META-INF/ 71 Mon Jan 10 09:31:14 CST 2005 META-INF/MANIFEST.MF 144 Tue Jun 22 14:45:42 CDT 2004 images/blank.png 251 Tue Jun 22 14:45:42 CDT 2004 images/file.png 229 Tue Jun 22 14:45:42 CDT 2004 images/foldericon.png 148 Tue Jun 22 14:45:42 CDT 2004 images/I.png 232 Tue Jun 22 14:45:42 CDT 2004 images/openfoldericon.png 152 Tue Jun 22 14:45:42 CDT 2004 images/T.png ! The META-INF/ directory entry is present, but not images/ Order is still OS-native. Now use WSAD to export this same directory structure as a jar file. Here's what I see when I dump it: C:\junk>jar tvf images-ibm.jar 25 Mon Jan 10 09:38:32 CST 2005 META-INF/MANIFEST.MF 148 Mon Jan 10 09:37:18 CST 2005 images/I.png 152 Mon Jan 10 09:37:18 CST 2005 images/T.png 144 Mon Jan 10 09:37:18 CST 2005 images/blank.png 251 Mon Jan 10 09:37:18 CST 2005 images/file.png 229 Mon Jan 10 09:37:18 CST 2005 images/foldericon.png 232 Mon Jan 10 09:37:18 CST 2005 images/openfoldericon.png Now the META-INF/ directory entry is gone too, and the order looks more like you'd see in UNIX. My bottom line: there may not be a specification for this, but there are times when it matters. In particular, as indicated originally, we have an internal application that has fairly wide use at our company and it requires entries for directories -- even if the directories are empty. WSAD/JAD should include options for retaining or deleting directory entries. I came across some 3rd party ant tasks and other wrappers of the jarring process that include a filesOnly() method to specifically remove directory entries or a KEEP_FILE_ORDER flag that, if true, prohibits re-ordering of entries and deletion of directory entries.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/jarpackager/JarWriter.java
Manifest manifest=  fJarPackage.getManifestProvider().create(fJarPackage);
				fJarOutputStream= new JarOutputStream(new FileOutputStream(fJarPackage.getAbsoluteJarLocation().toOSString()), manifest);
			} else
				fJarOutputStream= new JarOutputStream(new FileOutputStream(fJarPackage.getAbsoluteJarLocation().toOSString()));
			String comment= jarPackage.getComment();
			if (comment != null)
				fJarOutputStream.setComment(comment);
		} catch (IOException ex) {
			throw JarPackagerUtil.createCoreException(ex.getLocalizedMessage(), ex);
		}
	}
	
	/**
	 * Closes the archive and does all required cleanup.
	 *
	 * @throws	CoreException	to signal any other unusual termination.
	 * 								This can also be used to return information
	 * 								in the status object.
	 */
	public void close() throws CoreException {
		if (fJarOutputStream != null)
			try {
				fJarOutputStream.close();
				registerInWorkspaceIfNeeded();
			} catch (IOException ex) {
				throw JarPackagerUtil.createCoreException(ex.getLocalizedMessage(), ex);
			}
	}
	
	/**