4

I am currently working with a Java service wrapper. It works great, I can use my executable jar to install it a as a service, even pass along VM arguments while installing it as a service.

But since this is going to be deployed here and there, I was wondering how I can prevent people from retrieving the source files that are inside the Jar file. Is this possible? I was thinking of converting the jar file into a .exe file, and install it as a service like that, as I have found several tools capable of that. But They don't seem to allow me to pass VM arguments.

So does anyone have an idea how I should go about this thing?

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
user2524670
  • 277
  • 1
  • 3
  • 11
  • 1
    can you generate the jar file including only the *.class and not the *.java? – Matteo Gatto Sep 10 '13 at 12:04
  • possible duplicate of [Hiding the source code in .jar files](http://stackoverflow.com/questions/14492422/hiding-the-source-code-in-jar-files) – Eric Leschinski Sep 10 '13 at 12:04
  • 1
    As long as the source files are part of the jar file, they can be retrieved from it. Is their inclusion into the jar file required? Otherwise, you may want not to include them. If they are required, you could apply cryptography and obfuscation, thus making it harder to use them. – Abrixas2 Sep 10 '13 at 12:06
  • You could make it more difficult for users to understand if you obfuscate your code. – Josh M Sep 10 '13 at 12:54

1 Answers1

3

Your users must be able to run your .jar file. So you can't prevent them from knowing the code being run while also letting them run your code. You can only apply effort to make life difficult for the most common de-compiling and reverse engineering strategies.

If you must hide your code here are some options:

  1. .jar files already discourage people from viewing the source. Look in the .jar and you should not see source .java files (unless you specifically chose to include them). The .class files must be included and they can be de-compiled into a machine readable equivalent of your program, but it won't be easy to read or understand.

  2. Rewrite the program in C and then use an obfuscate program on the source and compile from that. This is about as locked and hidden as you can make it. Anyone who looks at your code will see completely humanly-incomprehensible gibberish that is so hard to modify to be understandable, it becomes much easier to just observe the program behavior and write a new program that imitates it.

  3. Convert your jar file to a .exe for windows: How can I convert my Java program to an .exe file?

Nuclear option:

If you have the sourcecode for the alien space ship/Iron man suit, and you must hide this code at any cost then you will need to remove the rights and liberties of the user using it while using your program. No single user must be allowed to observe or understand your program close enough to get a feel for how it is doing what it is doing. Third parties must be involved to randomize and obfuscate not only the code itself, but also the perception of how the user understands the tasks are being completed. A hired goon or mal-ware can monitor the users use of the program and electrocute the user or self destruct if it detects the hint that they are trying to understand or build upon your code. The sourcecode must become self aware and to delete itself on suspicious behavior.

Microsoft and XBox are using these sorts of strategies by removing the rights and liberties of users by writing hardware and software that bricks itself if you annoy the mothership. Pick up that can citizen. Don't make me taze you.

Community
  • 1
  • 1
Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
  • 1
    Who told you about my... uhm... what iron man suit? I see now indeed that it were the .class files and not .java, hadn't looked carefully enough my bad. I guess if it isn't readily readable with a simple text editor it's good enough thanks. – user2524670 Sep 10 '13 at 12:50