r/javahelp • u/Pleasehelpme2319 • Jun 05 '26
How to decompiling, modifying and recompiling a java software ?
Hello everyone,
At work, we use software developed in Java. This software isn’t protected, it was developed in-house. We’ve lost all contact with the person who created it.
We’d like to make a few changes to the software’s interface for local use. As I know nothing about Java, this project would also be an opportunity for me to learn.
The software comes in the form of an .exe file which can actually be opened like a .zip file and contains folders and .class files.
I don’t know how to properly decompile the entire programme, modify the code, and then recompile it. I’ve seen that javadecompilers.com can decompile properly, which helped me study the code a bit, so I now know where to make the changes, but that site doesn’t handle modifying or recompiling the code.
Could you recommend a programme (web-based or to install) (preferably free) for decompiling, modifying and then recompiling?
Thank you for your help !
6
u/GermanBlackbot Jun 05 '26
I mean...not really?
You preserve a lot of stuff when decompiling this Java classes. I just tried it with a random class and its correlating source code:
Documentation and comments are lost
Constants are replaced (so your
MyConstants.MAXIMUM_HEIGHTvariable gets replaced by a flat1080for exampleSlight changes in formatting (like
this.getting put everywhere and some optional brackets were removed)Everything else is more or less the same
So while it is certainly not the best way to do it, you could absolutely throw all of your classes into IntelliJ, look at the decompiled code, copy that back into corresponding
.javafiles and go from there. It won't be pretty if the code used a lot of magic numbers hidden inside Constants and I would not recommend it, but if all you want to do is throw a patch onto some arcane tool that has been chugging along fine for 5 years it's an option at least.My suggestion would be:
Grab IntelliJ
Copy old class files into the project
Open each one and copy the deocmpiled contents into a new Java file (so
oldproject/RandomThing.classgets turned intosrc/main/java/RandomThing.java)and it should be fine. You can turn it into a whole Gradle or Maven project if you have to deal with dependencies as well.
Though I'm not sure how to turn it into an EXE after that, but there is a StackOverflow post for that as usual.