Results 1 to 7 of 7
- 02-01-2013, 02:29 PM #1
Member
- Join Date
- Feb 2013
- Posts
- 6
- Rep Power
- 0
Difference between jar file created with the jar utility and the zip utility
I have also posted this in the "Java Software"-column. I'm not sure where exactly to place it, but Java-Software was definitely the wrong place! Unfortunately I couldn't move it, so I copied the whole stuff here.
For training purposes I created a jar file with the zip-utility. I edited the MANIFEST.MF-file and added it as well to the archive. But this gave me a "Invalid or corrupt jarfile" as I was told when I tried to start it with "java -jar ...". The I did the same with the jar-utility. This worked fine. The exploded versions of the jars don't show any difference.
This is the Ant I used to create both of this archives:
The content of the zipped jarfile is:Java Code:<!-- pack to repository.jar by zip --> <target name="jarRepository" depends="compileRepository"> <zip zipfile="${generate.dir}/repository.jar" > <fileset dir="${build.classes.dir}" includes="repository/**"/> <fileset dir="${repository}" includes="META-INF/**"/> </zip> </target> <!-- pack to repository.jar by jar --> <target name="jar2Repository" depends="compileRepository"> <jar jarfile="${generate.dir}/repository2.jar" > <fileset dir="${build.classes.dir}" includes="repository/**"/> </jar> </target>
0 Fri Feb 01 12:18:40 CET 2013 META-INF/
102 Fri Feb 01 12:03:30 CET 2013 META-INF/MANIFEST-MF
0 Fri Feb 01 12:16:46 CET 2013 repository/
1263 Thu Jan 31 11:07:58 CET 2013 repository/Activator.java
0 Thu Jan 31 09:38:50 CET 2013 repository/impl/
3356 Thu Jan 31 11:52:46 CET 2013 repository/impl/XMLRepositoryService.java
467 Fri Feb 01 12:03:08 CET 2013 repository/MANIFEST.TXT
0 Thu Jan 31 12:00:02 CET 2013 repository/META-INF/
102 Fri Feb 01 12:03:30 CET 2013 repository/META-INF/MANIFEST-MF
1408 Thu Jan 31 11:46:18 CET 2013 repository/Node.java
3 Fri Feb 01 08:27:22 CET 2013 repository/packageinfo
131 Thu Jan 31 09:22:48 CET 2013 repository/RepositoryService.java
The content of the "jared" jarfile is:
0 Fri Feb 01 12:04:02 CET 2013 META-INF/
106 Fri Feb 01 12:04:00 CET 2013 META-INF/MANIFEST.MF
0 Fri Feb 01 12:04:02 CET 2013 repository/
0 Fri Feb 01 12:04:02 CET 2013 repository/impl/
1610 Fri Feb 01 12:04:02 CET 2013 repository/Activator.class
2713 Fri Feb 01 12:04:02 CET 2013 repository/Node.class
251 Fri Feb 01 12:04:02 CET 2013 repository/RepositoryService.class
4911 Fri Feb 01 12:04:02 CET 2013 repository/impl/XMLRepositoryService.class
The content of the MAINIFEST.MF is in both cases:
Any idea what might be wrong?Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
Created-By: 1.6.0_38-b05 (Sun Microsystems Inc.)
brgds,
Ulrich
- 02-01-2013, 02:39 PM #2
Re: Difference between jar file created with the jar utility and the zip utility
You've zipped the *.java files, not the compiled *.class files.
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 02-01-2013, 02:40 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Re: Difference between jar file created with the jar utility and the zip utility
Those files are completely different ... the zipped version contains .java source files while the other one contains compiled .class files; the first version contains more entries; they can't be compared.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 02-01-2013, 04:15 PM #4
Re: Difference between jar file created with the jar utility and the zip utility
I deleted your other post.
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 02-01-2013, 04:37 PM #5
Member
- Join Date
- Feb 2013
- Posts
- 6
- Rep Power
- 0
Re: Difference between jar file created with the jar utility and the zip utility
Sorry, I tried this much with different parameters. At last I displayed one created with a false the wrong jarfile here. This is the correct one.
Sorry for the confusion. As you can see in the Ant-xml; the both of the tasks use the same directory to build the archive.0 Fri Feb 01 16:23:38 CET 2013 repository/
0 Fri Feb 01 16:23:38 CET 2013 repository/impl/
1610 Fri Feb 01 16:23:38 CET 2013 repository/Activator.class
2713 Fri Feb 01 16:23:38 CET 2013 repository/Node.class
251 Fri Feb 01 16:23:38 CET 2013 repository/RepositoryService.class
4911 Fri Feb 01 16:23:38 CET 2013 repository/impl/XMLRepositoryService.class
0 Thu Jan 31 12:00:02 CET 2013 META-INF/
102 Fri Feb 01 12:03:30 CET 2013 META-INF/MANIFEST-MF
When executing the archive with the sources it ends with message "Failed to Main-Class manifest attribute from .."
brgds,
Ulrich
- 02-04-2013, 11:00 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
Re: Difference between jar file created with the jar utility and the zip utility
From the docs.
"
Ant has been offering the encoding attribute of the zip and unzip task as a way to explicitly specify the encoding to use (or expect) since Ant 1.4. It defaults to the platform's default encoding for zip and UTF-8 for jar and other jar-like tasks (war, ear, ...) as well as the unzip family of tasks.
"
So, could be an encoding issue. If that's a Win platform it'll be encoded in that Win encoding whose name I've forgotten.Please do not ask for code as refusal often offends.
- 02-04-2013, 11:14 AM #7
Member
- Join Date
- Feb 2013
- Posts
- 6
- Rep Power
- 0
Similar Threads
-
Calling a method in a utility class
By TMobotron in forum New To JavaReplies: 2Last Post: 09-17-2010, 06:39 AM -
XML compare utility
By JMayura in forum Advanced JavaReplies: 0Last Post: 06-08-2010, 01:05 PM -
A utility class that parses a Comma Separated Values (CSV) file
By Java Tip in forum java.ioReplies: 0Last Post: 04-16-2008, 10:58 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks