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

前端 未结 2 870
野的像风
野的像风 2021-01-12 04:27

how can I decompile a jar and load it as a project in my Eclipse so I can modify the code ?

fyi I have googled jar decompiler. Looking for a guide or any insight on

相关标签:
2条回答
  • 2021-01-12 05:17

    I've used the Cavaj decompiler and it worked pretty well for me. You can just open up the jar file with any unzipping program like 7zip, .jar files are really just zip files. Then all you need to do is feed the .class files to Cavaj. The .class files are organized by package, so com.foo.Bar will be com/foo/Bar.class inside the .jar

    Like Danny said, legality might be questionable depending on the situation. I've only ever used it to look at the source for an older version of an application I wrote but no longer had the source for.

    0 讨论(0)
  • 2021-01-12 05:22

    Unless you also have the source code (either in the JAR, or separately), then the best you can do is to use a Java decompiler. Depending on how the code was compiled in the first place, this might generate source code which is significantly different to what the original author wrote (although functionally identical, of course). For example, certain optimizer options could result in loops being re-written and local variables being removed. Certain debug options could result in the names of local variables being removed, so the decompiler will have to invent (meaningless) names for them, etc.

    I would also question whether what you want to do is legal. Generally, if a project is licensed for modification then its source code will be available and you won't need to do what you're proposing.

    0 讨论(0)
提交回复
热议问题