Modify jar file

I have a jar file that is used in an html file as an applet. I want to change the contents of the jar file and rebuild the jar file so that html works perfectly with the new jar file. How can i do this?

I already tried to unpack using 7zip nad, modified the source and created a new jar. But when I use it in html, it shows some java.lang.Classnotfound error

+6
java eclipse jar
source share
5 answers

You can untie or recolor 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

+12
source share

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

I came across situations where the application launcher uses some validation and validates such changes. I had to use a new startup script. That doesn't seem to be your thing.

+2
source share

Disclaimer: When reverse engineering any code, make sure that you remain within the law and adhere to the license of that code.

Follow the instructions above to unzip the jar.

Find the source JAR source (possibly its on SourceForge) and load the source, change the source and rebuild your own JAR.

You can also decompile class files in a JAR. This is a fairly advanced process and has many "gotchas".

+1
source share

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

From the Java tutorials:

 jar uf jar-file input-file(s) 

"Any files already in the archive that have the same path as the file to be added will be overwritten."

See Updating the JAR File

A quick test shows that it quickly updates the changes, in addition to trying to delete the file.

I did not see an answer to other topics about changing jar files, and many, marked as duplicates, suggest that there is no alternative but to completely redo the bank. Please correct if you are mistaken.

+1
source share

JAR is just ZIP files, use any useful utility that you like and edit it!

0
source share

All Articles