Replace a single file from jar file

10,467

Maybe the jar -uf found here could help you: How to update one file in a zip archive

If graphical apps are an option, you could use winrar or 7-zip to replace the class. You don't need to extract the jar file to make this work. Just open the jar with one of those apps, go to de directory where is the class file to be replaced, drag-and-drop the new file to replace the old one and save.

Share:
10,467

Related videos on Youtube

programoholic
Author by

programoholic

Polyglot Programmer. Experience in CEAN STACK.

Updated on June 04, 2022

Comments

  • programoholic
    programoholic almost 2 years

    I need to replace a single class file from a jar file. The jar file is quite big and every time I don't want to extract it and replace manually. I want to automate this procedure. Can someone please help me on this. When jar file is extracted below folders are created :

    1. render
    2. classes
    3. com

    I need to go inside "com/cgp/f1/cmmi/" folder and replace a class file inside it.

    Things I tried :

    1. zip file.jar com/cgp/f1/cmmi/services.class Services.class
    2. jar uf file.jar com/cgp/f1/cmmi/ services.class
      jar -uf file.jar com\cgp\f1\cmmi\ services.class
      jar uf file.jar com/cgp/f1/cmmi/services.class services.class

    The error I am getting is :

    when using jar command
    com\cgp\f1\cmmi\ : no such file or directory

    when using zip command :
    zip warning: name not matched: com\cgp\f1\cmmi\Services.class

    can some one please guide me where I am going wrong.

  • programoholic
    programoholic almost 6 years
    The thing is, I want to update without using tools. Kind of automation.