1

Possible Duplicate:
Changing the code of the class from jar file

I'm coming with this from .Net, where there's Reflector and Reflexil, enabling me to open an assembly and edit its code without having to re-compile it. I did some research, and I've found jd-gui, which lets me view java code inside a jar, but I can't find anything that resembles reflexil.

Is there any software which would let me modify jars without having to re-compile them?

Community
  • 1
  • 1
Arsen Zahray
  • 24,367
  • 48
  • 131
  • 224

1 Answers1

4

A jar is just a zip, actually, so there's no recompiling. Just unjar it (using jar xf), add, replace or delete some files or directories, and jar it again (using jar cf).

Frank Pavageau
  • 11,477
  • 1
  • 43
  • 53
  • Yes, jar is just an archive, but it may contain binary .class files. How do I deal with that? Can I simply replace the binary .class files with .java files? – Arsen Zahray Sep 01 '12 at 22:12
  • @ArsenZahray Yes, and no. You can replace .class file only with another .class file. Use: javac nameofjavafile.java to compile your .java file to .class file. Than jar it again. – Branislav Lazic Sep 01 '12 at 22:15
  • how ho I compile the .java file, if the class inside it references other classes inside the jar? – Arsen Zahray Sep 01 '12 at 22:17
  • Use: javac -classpath /some/path/your.jar yourfile.java yourfile2.java ... – Frank Pavageau Sep 02 '12 at 10:25