3 Replies Latest reply: Apr 13, 2012 7:17 AM by maheshguruswamy RSS

    SECURING THE .CLASS FILES

    930450
      Hi,

      I am new to the forum. I am using java for almost 1.5 yrs now.
      I tried to search the topic in various forums also but I was not able to find any relevant information.

      During my projects I found a scenario in which I was supposed to secure my java code.
      Is there any API that provides me code security, so that other person can not de-compile my class file and get my source code?


      Thanks a lot in advance.
        • 1. Re: SECURING THE .CLASS FILES
          sabre150
          927447 wrote:
          Is there any API that provides me code security, so that other person can not de-compile my class file and get my source code?
          No. The reason is fairly obvious - before the JVM can execute your code it must have access to the plain class byte code. If the JVM can access the plain byte code then so can anyone else. Your best bet is to obfuscate your code using a Java obfuscater - Google is your friend. This will not stop de-compilation but it will make the decompiled code a hell of a lot more difficult to work with.

          P.S. Please don't use all capitals for all the title or body of your post - it looks like you are shouting and is considered rude.
          • 2. Re: SECURING THE .CLASS FILES
            aksarben
            As the other poster noted, if your code runs on the client's machine, there's no practical way to secure it. Two alternatives are:

            1. Run as a server based Web app instead. That way only YOU have access to the code.

            2. Make a living by selling support for your apps & don't be overly concerned about the code itself.
            • 3. Re: SECURING THE .CLASS FILES
              maheshguruswamy
              927447 wrote:
              Hi,

              I am new to the forum. I am using java for almost 1.5 yrs now.
              I tried to search the topic in various forums also but I was not able to find any relevant information.

              During my projects I found a scenario in which I was supposed to secure my java code.
              Is there any API that provides me code security, so that other person can not de-compile my class file and get my source code?


              Thanks a lot in advance.
              Most of the big software vendors dont care if you are able to decompile their source or not. But, they do have legal language in their terms of usage of their software. i.e. If you get caught decompiling their code, you will be definitely broke for the rest of your life. I suggest you do the same. Dont worry about putting any weird obfuscation code, instead get a good lawyer and have him/her write up your terms of usage.