I need to edit one line of code in the EJB. I import the ear into eclipse, but I cannot figure out how to edit the .class files. I can view them using Jadclipse, but I cannot edit them. I edited the .class file manually and put the revised .java file in the EJB and tried to export the ear, but it just deleted my .java. I guess my question is really how do I recompile my .java file into my project. I need to import an EAR, edit a .class file and开发者_运维问答 then export it as an EAR. This project was written for the business I am contracted to over 4 years ago. The developer that wrote it is no longer with us. So all I have is the EAR. Any help is appreciated.
Get yourself a good hex editor.
You can try decompiling the class files back into Java using a decompilier tool such as JD:
http://java.decompiler.free.fr/
Decompiliers are not perfect, however. The code they generate may not always be correct, so use with caution.
You don't edit .class files. It's the .java files that you edit and then compile into the .class files. I am assuming that the .java files must be in there as well if you can view them and update. Of course it is pointless to try to put the .java back in and export since the runtime will require the .class.
Of course, if it is EJB code inside an EAR, it is quite possible that it is either generated code, or code that will have to be run through an EJB compiler to produce a proper EJB.
You cannot edit class file, but you can try to edit bytecode in runtime, try javassist
An EAR file is just a zip file. Rename it to .zip and you can view it in WinZip or whatever.
Then if you are lucky you can decompile the file and make any mods you need to the file (I say lucky because it depends how the file was compiled, obfuscated or without any debug info).
Use ANT to rebuild the EAR (See How do I create an EAR file with an ant build including certain files? or some other resource)
You should be good to go, just redeploy the new EAR.
精彩评论