How to protect a Jar file from being decompiled? [duplicate]

怎甘沉沦 提交于 2019-12-17 19:39:02

问题


I'm developing an application using java but I'm not going to release the code. The problem is, I tested one of these jar de-compilers and it was able to get the code from my jar file almost perfectly! My question is how can I distribute my jar file without my code being extracted from it?


回答1:


As Java preserves most of the "metadata" during compilation (which allows dynamic loading and reflection), it is a straight forward to decompile (not only disassemble) the compiled class files. That's why the recovered code is very similar to the original.

While not perfect, your probably only option is to use an obfuscator, such as ProGuard.




回答2:


You can't. At the minimum, the JVM is going to need to get the code out in order to run it. And if the JVM can get the code out, anyone can.

The best you can do is obfuscate the code, but I would recommend against it because it will make tracking down production bugs very difficult because the stack traces will be hard to follow.




回答3:


There is no possibility to protect the code from disassembling. You can use obfuscation tool like 'proguard'. Even after decompilation it will be almost impossible to understand the code.




回答4:


Obfuscate your code using some obfuscator in the market. Obfuscators change the names of your class and its methods to some weird looking names so that it becomes hard for people to make sense of the code. Mind it, people would still be able to decompile your code but only thing is it would be hard for them to understand it due to the jumbled names.

Downside of this is, it would be hard for you to debug and support the obfuscated code in case your customer faces some issues as the stack traces in the exceptions would have the jumbled up class and method names.




回答5:


it's never impossible to reverse-engineer in java but i think that Proguard is the best. It is also possible to integrate it with your IDE (for example NetBeans). and ygard for ant



来源:https://stackoverflow.com/questions/9633455/how-to-protect-a-jar-file-from-being-decompiled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!