Search code examples
javajar

How to create jar file from existing jar file?


I have not worked on java till now.... But i need to include the jar file into my project.

I have one jar created already with me. But i need to update this jar file. I don't have source of those project.

It has folder structure like follow

1. folder which has .class file.
2. com folder
3. de folder
4. META-INF folder contains MANIFEST.INF file and Maven folder
5. org folder
6. config.properties
7. abc.builds.properties

I need to update config.properties and create new jar file.

Can anybody help me in this?


Solution

  • The procedure is roughly this:

    1. Create a temporary directory and cd to it.
    2. Use jar xf file.jar to extract the JAR file.
    3. Add, edit, remove files
    4. Use jar cf new-file.jar .... to create the new JAR file.

    It is also possible to update individual components with jar uf file.jar ...

    (If the original JAR file was signed, you will need to re-sign it ... if you need a signed JAR.)