简体   繁体   English

我可以制作一个只在我的电脑上运行的 Java 程序吗?

[英]Can i make a java program to run only on my computer?

I need to make a program to run only on my pc.我需要制作一个只能在我的电脑上运行的程序。 No one should be able to copy it and run it on their computer.没有人应该能够复制它并在他们的计算机上运行它。 Is there any way in java to accomplish that? java中有什么方法可以做到这一点吗?

You can try, but you can't come up with a surefire way to prevent for example me from running it.您可以尝试,但您无法想出一种万无一失的方法来阻止例如我运行它。 Any security checks and obfuscations you put in place can be removed given enough time, so the only way to prevent it from being run is not to distribute it.如果有足够的时间,您可以删除任何安全检查和混淆,因此阻止它运行的唯一方法是不要分发它。

Of course it's quite unlikely that I (for example) would even bother attempting to crack your program, since I'm almost positive that it would be a waste of my time.当然,我(例如)不太可能尝试破解您的程序,因为我几乎可以肯定这会浪费我的时间。

Supposing you have a network adapter on the computer you want to run your program on (you have it if you can connect to the internet) and :假设您要在其上运行程序的计算机上有一个网络适配器(如果您可以连接到互联网,则拥有它)并且:

  • that you won't change it你不会改变它
  • or that you'll adapt your program when you change it或者当你改变它时你会适应你的程序

you can test, when you start the program, that :您可以在启动程序时测试:

  • the computer running your program has a MAC address (the MAC address depends on your network adapter)运行您程序的计算机有一个 MAC 地址(MAC 地址取决于您的网络适配器)
  • and that the MAC address that is loaded equals your MAC address (that you've written in your program as a constant ideally in a properties file)并且加载的 MAC 地址等于您的 MAC 地址(您在程序中作为常量理想地写入属性文件中)

You get the MAC address like this :你得到这样的 MAC 地址:

InetAddress localhost;
try
{
    localhost = InetAddress.getLocalHost();
    byte[] macAddress = NetworkInterface.getByInetAddress(localhost).getHardwareAddress();
}
catch (UnknownHostException e)
{
    e.printStackTrace();
}
catch (SocketException e)
{
    e.printStackTrace();
}

But it's a little bit time consuming.但这有点费时。

From what you're saying, you don't seem to want it to run on only one computer, but instead you seems to want to be the only one to be able to run it.从你所说的来看,你似乎并不希望它只在一台计算机上运行,​​而是你似乎希望成为唯一能够运行它的计算机。

In that case, what you can do is have a ciphered application.在这种情况下,您可以做的是拥有一个加密的应用程序。

You create your application as you please, you cipher it with a (strong) password and you wrap it into an uncipher + launcher application.您可以随意创建应用程序,使用(强)密码对其进行加密,然后将其包装到 uncipher + 启动器应用程序中。 Then you delete your original application.然后你删除你原来的应用程序。

A good way of implementing it requires advanced techniques such as cryptography and dynamic class loading (to avoid leaving traces on the disk), and I'm not even speaking about the building system.实现它的好方法需要高级技术,例如密码学和动态类加载(以避免在磁盘上留下痕迹),而且我什至不是在谈论构建系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM