Protect class files from decompilation

D

Dave

I understand that it is relatively easy to decompile Java class files into
source code.

How can I protect my application from being decompiled?
 
A

Alex Hunsley

Dave said:
I understand that it is relatively easy to decompile Java class files into
source code.

How can I protect my application from being decompiled?

You can't. What you can do, however, is use an obfuscator (e.g. ProGuard
- google for "java obfuscator" for more) which makes the resulting
decompiled code harder to understand/reuse/ripoff. Obfuscation usually
reduces the compiled bytecode size too.

All
 
A

Alex Hunsley

Dave said:
I understand that it is relatively easy to decompile Java class files into
source code.

How can I protect my application from being decompiled?

Forgot to add - one 'defence' is to not give them your class files at
all, but present your code as a web application (e.g. using Tomcat +
servlets). May not be practical though.
 
D

Dave

Alex Hunsley said:
You can't. What you can do, however, is use an obfuscator (e.g. ProGuard -
google for "java obfuscator" for more) which makes the resulting
decompiled code harder to understand/reuse/ripoff. Obfuscation usually
reduces the compiled bytecode size too.

Sounds good, thanks.
 
L

Laurent D.A.M. MENTEN

xmx said:
Maybe you can encrypt your class file and implement your own classloader

And as the custom classloader has to be be shipped with the encrypted
class...
 
A

Andreas Leitgeb

Alex Hunsley said:
You can't. What you can do, however, is use an obfuscator ...

Or better yet, write code that you don't need to
feel ashamed of to show. ;-)

scnr.
 
L

Lew

Andreas said:
Or better yet, write code that you don't need to
feel ashamed of to show. ;-)

Or write code that performs so awfully that no one would want to decompile it.

Seems stupid, but I've seen an awful lot of code in production that seems to
follow that philosophy.

- Lew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top