This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes Protecting the java source code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Protecting the java source code" Watch "Protecting the java source code" New topic
Author

Protecting the java source code

Anand Sidharth
Ranch Hand

Joined: Dec 17, 2003
Posts: 44
Hi,
Is there anyway in java by which I can prevent people from viewing the source code(by decompiling) of a tool created using java(a jar file).
Anand
Anand Sidharth
Ranch Hand

Joined: Dec 17, 2003
Posts: 44
Let me put the question again properly
:
Java bytecodes could be easily decompiled and hence lots of work done on the code is there for every body to see.
Is there any way by which we can prevent this either directly or indirectly???
Thanks in advance.
Anand
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
There are some tools out there which claim to garble the bytecode in such ways that the JVM can still use it but decompilers cannot.
I've never tried them so can't tell you their effectiveness.
The first thing to do is turn off debugging info in your release build using the -g:none option of javac.


42
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

http://www.codingart.com/codeshield.html


Groovy
Anand Sidharth
Ranch Hand

Joined: Dec 17, 2003
Posts: 44
Thanks Pradeep,
I will try using CodeShield.
Are u aware of any Freeware like CodeShield.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Anand,
Have a look at this one
http://www.jproof.com/
Tanveer Rameez
Ranch Hand

Joined: Dec 11, 2000
Posts: 158
jarsafe is a good tool .It converts all class files in a jar into .jarsafe files after encrytping them...i used it and it weas effective. but now jarsafe is not found online. Can anyone tell me where i can get jarsafe..even its trail verison?
its old site was http://jarsafe.com


Author of JPhotoBrush Pro (www.jphotobrushpro.com)
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

No, it is impossible and all attampts to claim otherwise are false. If you allow your program to run, then it must be decrypted during or before that time. Thus, whoever can run your program can see the class files for it and can decompile them.
Any real solution must involve DRM.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
[CLG]: No, it is impossible and all attempts to claim otherwise are false.
Well, it's always going to be possible to recover JVM bytecodes from the jar file. But with good bytecode obfuscation it can be difficult to recover a human-readable version of the source code. At the very least, you can replace all your helpful variable and method names with names lie a, b, c(), d(), etc. I haven't kept up with the state of the art in obfuscation, so I don't know just what else is possible, and how good decompilers have grown in response. It will probably always be possible for others to reverse engineer your work if they're determined enough - but at least, you can make them work for it.


"I'm not back." - Bill Harding, Twister
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
When you're searching around for such a tool, the keyword to use is "obfuscator" or "Java code obfuscator", since such tools are called obfuscators.
[ I swear Jim's post wasn't here a minute ago. ]
[ January 09, 2004: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Protecting the java source code