I have created a plugin project in Eclipse, distributed as a jar. The user can take this jar and decompile it using JAD. Is there any way so that i can stop the decompilation of a jar file? Or, at least, to hide my source code from the user?
-
Please edit your question because it's really hard to understand. – Danubian Sailor Dec 06 '11 at 10:16
-
possible duplicate of ["undecompilable" source code in java](http://stackoverflow.com/questions/3797055/undecompilable-source-code-in-java) – Dec 12 '11 at 06:08
2 Answers
The best way to stop your jar from being decompiled is to give users no reason to want to. Obfuscation is just a bandaid. In fact, some people will probably reverse it just for the challenge if it's famous enough.

- 37,781
- 10
- 100
- 107
-
+1 What a great answer! "You're a lot more likely to beat would-be pirates through frequent, meaningful updates than you are by bothering your customers with increasingly onerous security measures." http://www.codinghorror.com/blog/2005/05/obfuscating-code.html – Erick Robertson Oct 03 '13 at 05:05
-
Agree, because if your code transferred and executed into another environment / host - it could be: stopped, debugged, evaluated, transformed etc. You only **could try** to harden this or, as @Antimony said, give no reason to do it: 1) use technologies that require a more higher level of knowledge to decompile (see f.e. http://www.jproductivity.com/); 2) have a low price for your product, 3) use cloud/server logic (don't move code to the client). Also see here: http://stackoverflow.com/questions/2443542/how-to-protect-compiled-java-classes – lospejos Jul 21 '16 at 21:10
If you don't insert your source code in the jar, your sourcecode isn't what is decompiled by a decompiler, but something similar.
However, you may use an obfuscator to make code decompilation produce very ugly code like Proguard.
ProGuard is a free Java class file shrinker, optimizer, obfuscator, and preverifier. It detects and removes unused classes, fields, methods, and attributes. It optimizes bytecode and removes unused instructions. It renames the remaining classes, fields, and methods using short meaningless names. Finally, it preverifies the processed code for Java 6 or for Java Micro Edition.
Search for other products with the term obfuscator.

- 35,537
- 11
- 75
- 121