How to make a Java Program unextractable

2019-02-23 18:45发布

Sorry I am not very sure how to state the question title. My problem is like this, I had developed a Java program, and I wish to distribute it to my friends. So I export it to Jar file, but I don't want them to extract the jar file to view the code. Is there anyway to make the program so that nobody can get the source code instead just launch the program.

7条回答
Deceive 欺骗
2楼-- · 2019-02-23 18:54

You can always get the original code back from compiled class files. However, you can make the lives of those who wish to decompile such code very difficult by using an obfuscator, so the decompiled code is nearly impossible to read. Here is a list of open-source java obfuscators which you might wish to investigate.

查看更多
聊天终结者
3楼-- · 2019-02-23 18:57

If a computer can run it, a human can reverse engineer it.

查看更多
祖国的老花朵
4楼-- · 2019-02-23 18:58
  1. The term you are looking for is obfuscation. Ultimately
At best, obfuscation merely makes it time-consuming, but not impossible,

to reverse engineer a program.

  1. Another technique is SaaS. Though ultimately using black box techniques SaaS is also reverse-engineerable.
  2. Another technique is trust. Since you are distributing it to your friends, you could ask them to not extract the jar file or view the code. If they are really your friends, they will honor your request.
查看更多
啃猪蹄的小仙女
5楼-- · 2019-02-23 19:00

You appear to be confusing the installation application with the executable. And I also think you are confusing a java jar application with a normal .exe.

Even then, these are all just bundles of code which can still be decompiled, it's just not as easy as unpacking a jar file, which are designed to be easy to extract.

Java is designed to run on the JVM, so packing it inside a .exe is poor form as that immediately locks it onto Windows, which defeats the point of Java in the first place. So I would advice against that.

As everyone has stated, it is rare that if your program works well and you users like it, that they would even think to decompile it. But if they want to they are just a single web search from a how to anyway (regardless of the language). With regards to commercial distribution, most cases the software is obfuscated and distributed in it's .jar, with with a architecture specific launcher of the form .exe, .app, .bin etc. Do not confuse those with the actual executable which is generally a .jar file somewhere.

查看更多
放我归山
6楼-- · 2019-02-23 19:06

Jar files typically do not contain code. They usually only contain the .class (bytecode) files necessary to run the program.

查看更多
爷、活的狠高调
7楼-- · 2019-02-23 19:08

You could execute part of your program on a server. Basically to execute some important, large and central function of your program, the clients contact your server to compute this function.

Then you can distribute the clients to everybody, and keep the server code for your self. Just keep the server running. Then the others can't get access to whole source, but can execute the software.

This is the only sure way to do this. Other ways can be circumvented in some ways with enough effort.

查看更多
登录 后发表回答