Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jar File - Prevent Access to Source Code

I want to hand over a small Java app as a runnable jar but I do not want anybody to have access to my source code. Am I right in presuming that there is no source code (.java files) included with a jar file?

User269799

like image 252
Grunge Freak Avatar asked Dec 03 '22 09:12

Grunge Freak


2 Answers

Assuming you don't put the java files in the jar file, they're not going to magically appear :) You can include anything you like in the jar file of course. You can list the contents to check:

jar tvf foo.jar

Note that Java can be decompiled pretty easily though - so while any recipients wouldn't have access to your actual source code with comments etc, they could see your logic pretty clearly. You may want to use an obfuscator to help protect your IP. Personally I try to avoid obfuscators - given how hard most of us find to maintain code when we do have the real source with commments and tests, imagine how hard it is when you don't have those things :) It's your call though. Just make sure you test obfuscated code thoroughly - there can be subtle issues, particularly if you use reflection.

like image 75
Jon Skeet Avatar answered Dec 07 '22 22:12

Jon Skeet


If a computer can run it, a human can reverse engineer it, and it is not particularly hard for Java.

So technical protection simply won't work. You need legal protection in form of a binding contract or similar. You may even put your works under the GPL except for those paying you, which is sufficient for most businesses to avoid stealing your work.

What situation exactly do you want to avoid?

like image 20
Thorbjørn Ravn Andersen Avatar answered Dec 07 '22 23:12

Thorbjørn Ravn Andersen