Updating .class file in jar

后端 未结 11 835
南笙
南笙 2020-11-27 05:52

I want to update a .class file in a jar with a new one. What is the easiest way to do it, especially in the Eclipse IDE?

相关标签:
11条回答
  • 2020-11-27 06:08

    Editing properties/my_app.properties file inside jar:

    "zip -u /var/opt/my-jar-with-dependencies.jar properties/my_app.properties". Basically "zip -u <source> <dest>", where dest is relative to the jar extract folder.

    0 讨论(0)
  • 2020-11-27 06:09

    This tutorial details how to update a jar file

    jar -uf jar-file <optional_folder_structure>/input-file(s)     
    

    where 'u' means update.

    0 讨论(0)
  • 2020-11-27 06:11

    1) you can extract the file into a folder called

    jarname.jar

    and then replace the file in the folder, handy if you are updating the class a lot while debugging

    2) you can extract the jar replace the file then the jar it up again

    3) Open the jar with 7 zip and drag and drop your new class in to copy over the old one

    0 讨论(0)
  • 2020-11-27 06:13

    Do you want to do it automatically or manually? If manually, a JAR file is really just a ZIP file, so you should be able to open it with any ZIP reader. (You may need to change the extension first.) If you want to update the JAR file automatically via Eclipse, you may want to look into Ant support in Eclipse and look at the zip task.

    0 讨论(0)
  • 2020-11-27 06:13

    You can find source code of any .jar file online, import the same project in your IDE with basic setups. Make necessary changes in .java file and compile it for .class files.

    Once compilation is done You need to extract the jar file, replace the old .class file with new one.

    And use below command for reconstruct .jar file

    Jar cf test.jar *

    Note : I have done so many time this changes in our project, hope you will find it useful.

    0 讨论(0)
  • 2020-11-27 06:17

    Simply drag and drop your new class file to the JAR using 7-Zip or Winzip. You can even modify a JAR file that is included in a WAR file using the parent folder icon, and click Ok when 7zip detects that the inside file has been modified

    0 讨论(0)
提交回复
热议问题