10 Replies Latest reply: May 11, 2012 7:14 AM by gimbal2 RSS

    How to protect a .jar

    804261
      Protect a archive .jar (password) or another way... How ??
        • 1. Re: How to protect a .jar
          796440
          What do you mean "protect" it? What are you trying to accomplish?
          • 2. Re: How to protect a .jar
            EJP
            Protect it from whom? Doing what?
            • 3. Re: How to protect a .jar
              804261
              protect my code, for example when I build my project "Project1", NetBeans make a Project1.jar, this archive can be extracted and can be look the code. Ok the point is, can I make a solution when other people cant look my code or don't extracted the .jar
              • 4. Re: How to protect a .jar
                796440
                801258 wrote:
                protect my code
                You don't need to do that.
                can I make a solution when other people cant look my code or don't extracted the .jar
                Not in any practical sense, no. For the contents of the jar file itself, it must exist unencrypted for the JVM to run it. If it's running on my computer, I can examine it. Period. You cannot change that. You can use an obfuscator on the source code so that it will be harder to decompile, but that won't stop someone who's really determined.

                You need to step back and take a more realistic look at things.

                1. How badly do you really, honestly think anybody is going to want to steal your code? Seriously, is it that great? That revolutionary? That unique and unlikely for somebody else to be able to come up with the equivalent?

                2. How much actual, real damage will you incur if they do? I'm talking about actual financial loss here, not just, "But I don't want them to!"

                3. Putting the first two together, how much time, effort, and money is it worth to you to try to stop it?
                • 5. Re: How to protect a .jar
                  EJP
                  protect my code, for example when I build my project "Project1", NetBeans make a Project1.jar, this archive can be extracted and can be look the code.
                  No they can't. That .jar file doesn't contain your code.
                  • 6. Re: How to protect a .jar
                    804261
                    Ok Im a amateur not a professional, im just have the curiosity to put a password in a .jar, when a person extract the .jar show to input the password ONLY THAT its my curiosity. Yes I dont have to protect but I want to now that.
                    • 7. Re: How to protect a .jar
                      796440
                      If you want to password protect your jar file, that has nothing to do with Java. That would be an OS or File System level utility (if you want it to be transparent, so that the user only has to enter one password for multiple files, for example), or a 3rd party utility that you can use to encrypt or decrypt any file.

                      It's difficult to give proper advice when you don't clearly and accurately express your real requirements.
                      • 8. Re: How to protect a .jar
                        935982
                        " it must exist unencrypted for the JVM to run it" - it is wrong. You can encrypt .jar and then use JarClassLoader to load this .jar, decrypt it and load its cllasses into VM.
                        • 9. Re: How to protect a .jar
                          EJP
                          At the point when the code is executed, it must be unencrypted. It is not in principle impossible to intercept the code at that point.
                          • 10. Re: How to protect a .jar
                            gimbal2
                            EJP wrote:
                            At the point when the code is executed, it must be unencrypted. It is not in principle impossible to intercept the code at that point.
                            Plus you can't encrypt the classloader class that does the decryption. Its a futile effort to even write such a weak protection scheme.