如何使 Java 程序不可提取
抱歉,我不太确定如何陈述问题标题。我的问题是这样的,我开发了一个Java程序,我想将它分发给我的朋友。所以我将其导出到 Jar 文件,但我不希望他们提取 jar 文件来查看代码。无论如何,有没有办法制作该程序,以便没有人可以获得源代码,而只是启动该程序。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您始终可以从编译的类文件中获取原始代码。然而,使用混淆器会使那些希望反编译此类代码的人变得非常困难,因此反编译的代码几乎无法阅读。以下是您可能希望研究的开源 Java 混淆器列表。
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.
如果计算机可以运行它,那么人类就可以对其进行逆向工程。
If a computer can run it, a human can reverse engineer it.
事实是没有人想要你的源代码。认为值得付出努力将他们拒之门外的想法是相当傲慢的。
你能做的最好的事情就是混淆视听。
The truth is that nobody wants your source code. It's pretty arrogant to think that it'd be worth the effort required to keep them out.
The best you can do is obfuscate.
Jar 文件通常不包含代码。它们通常只包含运行程序所需的
.class
(字节码)文件。Jar files typically do not contain code. They usually only contain the
.class
(bytecode) files necessary to run the program.您似乎将安装应用程序与可执行文件混淆了。我还认为您将 java jar 应用程序与普通的 .exe 混淆了。
即便如此,这些都只是仍然可以反编译的代码包,只是不像解压 jar 文件那么容易,而 jar 文件的设计是为了易于提取。
Java 被设计为在 JVM 上运行,因此将其打包到 .exe 中是一种糟糕的形式,因为这会立即将其锁定到 Windows,这从一开始就违背了 Java 的初衷。所以我建议反对。
正如大家所说,如果你的程序运行良好并且用户喜欢它,他们很少会考虑反编译它。但如果他们愿意,他们只需通过网络搜索即可找到如何操作(无论使用何种语言)。关于商业分发,大多数情况下,软件被混淆并以 .jar 形式分发,并具有 .exe、.app、.bin 等形式的特定于体系结构的启动器。不要将它们与实际的可执行文件混淆,后者通常是.jar 文件某处。
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.
您可以在服务器上执行部分程序。基本上,为了执行程序的一些重要、大型和核心功能,客户端会联系您的服务器来计算该功能。
然后你可以将客户端分发给每个人,并保留服务器代码。只需保持服务器运行即可。然后其他人无法访问整个源代码,但可以执行该软件。
这是唯一可靠的方法。只要付出足够的努力,其他方法就可以通过某些方式规避。
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.