0

Using the standard Java API (i.e. the user doesn't need the JDK to run it), how do you make a function similar to jar -uf in Java? I have an idea that it will use the Zip library, unzip the .jar file, change the contents, and then rezip it, but I'm a newbie at Java, so I cannot really make it. Could you give an example or a function?

Thanks!

Edit: I think I found the answer here: How to use JarOutputStream to create a JAR file? I'll see if it works.

Community
  • 1
  • 1
MiJyn
  • 5,327
  • 4
  • 37
  • 64
  • May be util.zip API help you. Refer this link http://docs.oracle.com/javase/6/docs/api/java/util/zip/package-frame.html – kosa Feb 14 '12 at 16:43
  • Yeah, I saw that. My question is if someone could make a function or an example because I'm not an expert in Java (just learning). – MiJyn Feb 14 '12 at 17:10

1 Answers1

0

Take a look at JarInputStream, JarOutputStream, ZipInputStream, and ZipOutputStream. They are a part of the JDK, so external libraries are not required. Pay attention that unlike other streams these require you to care about current entry. You can find a lot of examples of how to use the java zip API.

Sean Reilly
  • 21,526
  • 4
  • 48
  • 62
AlexR
  • 114,158
  • 16
  • 130
  • 208