Eclipse: How to decompile jar and load it as a project?

How can I decompile a jar and load it as a project in my Eclipse so that I can change the code?

fyi I have a jog googled decompiler. Looking for guidance or any idea of ​​experience with it.

+4
source share
2 answers

If you also do not have the source code (either in the JAR or separately), then it is best to use a Java decompiler. Depending on how the code was compiled in the first place, this can generate source code, which is significantly different from what the author wrote (although functionally identical, of course). For example, some optimizer options can overwrite loops and delete local variables. Some debugging options can delete local variable names, so the decompiler will have to invent (meaningless) names for them, etc.

I would also ask if what you want to do is legal. Typically, if a project is licensed for modification, its source code will be available and you will not need to do what you offer.

+3
source

I used the Cavaj decompiler and it worked very well for me. You can simply open the jar file with any unzip program such as 7zip, .jar files are just zip files. Then all you have to do is submit the .class files to Cavaj. The .class files are organized by the package, so com.foo.Bar will be com / foo / Bar.class inside .jar

As Danny said, legitimacy can be questionable depending on the situation. I only ever used it to look at the source of an old version of an application that I wrote, but no longer had a source for.

0
source

All Articles