Rather than using a hex editor, one might consider a tool like Soot from McGill's Sable group. It includes a DSL for dealing with bytecode:<p><a href="https://github.com/Sable/soot" rel="nofollow">https://github.com/Sable/soot</a><p>I had looked at Soot some time ago because of Dava, the Java decompiler included with the project.<p>Also, for programatic manipulation of bytecode, ASM is a great tool:<p><a href="http://asm.ow2.org/" rel="nofollow">http://asm.ow2.org/</a><p>It includes a Java source generator which, given a .class file as input, produces a Java source class which will regenerate the input via the ASM builder APIs. Obviously, the benefit is that you get a starting point for building various re-writers, analyzes, etc.