Reimport class and update manifest file to jar file
Hi there,
I have a signing jar file, its META-INF/MANIFEST.MF file has digest values, something like this:
Manifest-Version: 1.0
Created-By: 1.5.0_06 (Sun Microsystems Inc.)
Name: abcd.class
SHA1-Digest: l7+fWxVnj2DIDb0a6FyUGxlNPUY=
Name: xyz.class
SHA1-Digest: qy/F9+YzIX6XrYd7kcHxLzXayjI=
Is there any way to update abcd.class and then re-import it again into jar file? Because the MANIFEST file is signed and verified, we have to update MANIFEST file too, haven't we?
I have an idea, make the jar file by ourself, based on the available .class files, without sign or verification. But I haven't succeeded so far. Could you tell me how to do, please?
Thanks for your help in advance.
Best regards,
[774 byte] By [
Lehoanqa] at [2007-11-27 0:26:18]

# 1
The best way to do this would be to rebuild the JAR using the contents of the existing JAR file.Export the contents of the signed JAR and then replace the class that you have changed.Simply rebuild the JAR from the command line.
# 2
You're right. But I have some problem with remaking jar file. You know, it's an applet jar file in fact. When I see its content by using WinRar, there're many unmeaning class name: A.class, B.class and even a.class (case insensitive). I have to unzip it in Linux environment to not overwrite these files. I don't know how to rejar it. I tried to unjar, made no change and rejar, but not sucessful. Could you help me, please?
Thanks so much!
# 3
Are you trying to rejar it through the command line? What command are you using?
# 4
Yeah, I'm using CL, like this:
jar cvfm Test.jar mymanifest -c com -c images A.class a.class aa.class ab.class
with mymanifest is a very simple manifest file.
The problem I think it's because of structure of jar file. A lot of unmeaning file .class. Hereafter is a example, www.jscape.com/sftpapplet/pub/sftpapplet.zip . That may prevent us to rejar correctly.
Please take a look at that file. If you unjar and rejar successfully, please tell me how to do. Thank you very much!
Best regards,
# 5
C:\temp\ForExamp\real>jar -cvfm sftapplet-unsigned.jar c:/temp/ForExamp/MANIFEST.MF .
I used this command.
Export the contents of the jar within the unisigned directory to some directory, in my case I placed it in my temp/ForExamp/real directory.
I then moved the MANIFEST file outside of the real directory to the ForExamp directory.
In the command line I make the current directory C:/temp/ForExamp/real.
In the command I specify the absolute path to the MANIFEST.MF file which I moved.
I specify a . to include all files and directorys in the current directory to the JAR file.
Make sure jar.exe is in your PATH environment variable or Windows will not recognize jar as a command.
Worked fine for me.
# 6
You're right again :-)
Just more addition, the CL should include some folders: a, b, com.
It works, great! But it's my fault, I gave you the unexpected jar file. Let me give you another one: http://sftp.thinfile.com/ThinFTPAppletDemo.zip
This jar file has many classes with case sensitive. I don't have any linux machine now. If you can, please unjar, and rejar for me. Tomorrow I will test in Linux environment (case sensitive).
Thank you so much for your help so far!
Wish you all the best!
# 7
I don't understand why you still can't do this yourself?I just showed you how to do it.It is practically the same thing to do this on a linux machine. I just happened to show you a Windows example.
# 8
Dear maple_shaft,
As I said above, I gave you the wrong jar file. Because I could you like you do, it worked. Sorry for taking your time for it. So I've been asking you to try just one more time with this jar file: http://sftp.thinfile.com/ThinFTPAppletDemo.zip
I unjar and rejar in Linux env., but the applet cannot init.
Look like I'm disturbing you so much. Of course if you're interested in this issue, please help me. Thank you deeply.
Best regards,
# 9
Oh I finally understand your problem now!!!
Windows is case insensitive when it comes to file names. This archive was generated on a Unix based machine so a.class in Windows is thought to be the same as A.class!
There is no way that I can JAR this file correctly for you because I do not have access to a Unix machine right now. You can only rejar this file in a Unix environment unfortunately.
I must comment however that whoever developed this JAR file chose a HORRIBLE design. Why would anyone name their classes in this way?
Sorry I couldn't help you out.
# 10
No, don't mind, you helped me a lot. Thanks so much!
You know, this jar is made by some Java tools to obstruct someone who try to access it, usually a commercial one.
I don't know if someone can give us a small trick to solve this problem. Just like resource hacker in Windows application.
Thanks again.
Good luck,