Modifying a jar file

后端 未结 5 1108
轮回少年
轮回少年 2020-12-30 09:47

I have a jar file which is used in html file as applet. I want to modify the content of the jar file and to rebuild the jar file so that the html will work fine with the new

相关标签:
5条回答
  • 2020-12-30 10:26

    Make the changes in the code (.java files), recompile to get the .class files. Then simply replace the old .class files in the jar with the new ones. I usually use WinZip, but you can use whatever app that can handle .Zip files. It should just work.

    I've faced cases where the launcher of the app uses some sort of verification and checks for this kind of changes. I had to use a new launch script. This doesn't seem to be your case though.

    0 讨论(0)
  • 2020-12-30 10:35

    You can unjar or rejar the classes and source files as you wish.

    unjar

    jar -xvf abc.jar 
    

    jar

    jar cf abc.jar input-files
    

    http://docs.oracle.com/javase/tutorial/deployment/jar/build.html

    0 讨论(0)
  • 2020-12-30 10:35

    JARs are just ZIP files, use whatever utility you like and edit away!

    0 讨论(0)
  • 2020-12-30 10:36

    Disclaimer: When reverse engineering any code be sure that you are staying within the limits of the law and adhering to the license of that code.

    Follow the instructions above to unpack the JAR.

    Find the original source of the JAR (perhaps its on SourceForge) and download the source, modify the source, and rebuild your own JAR.

    You can also decompile the class files in the JAR. This is a rather advanced process and has a lot of "gotchas".

    0 讨论(0)
  • 2020-12-30 10:37

    This is surely possible from the command line. Use the u option for jar

    From the Java Tutorials:

    jar uf jar-file input-file(s)
    

    "Any files already in the archive having the same pathname as a file being added will be overwritten."

    See Updating a JAR File

    A brief test shows this quickly updates changes apart from trying to delete the file.

    I haven't seen this answer on other threads about modifying jar files, and many, marked as duplicates, suggest there is no alternative but to remake the jar completely. Please correct if wrong.

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