That depend.
1) If you are talking about android code (calsses.dex), you can disasm it using apktool, and then inject/edit the disassembled code. Finally you can reassemble that code (still using apktool, and ofcourse your new code should not contain syntax errors). You will also need to sign your new apk to be able to run it on your android device.
2) If you are just trying to get the source code from some jar, you can just decompile them using a decompiler like JDGUI and the get the source code (in JAVA lang). Be aware that your jar files might be obfuscated, so the resulting source code might be confused or just not working.
I'd say that if you have an apk with that code you want to modify, your best bet is disassembling it with apktool. Else if you are trying to do that just to recover a source code form jars (maybe have you lost your original source code??) you can try a decompiler.
Hope this helps.