简体   繁体   English

创建一次只能运行的Java应用程序

[英]create a run-only-once java application

I have to create a jar with a java application that fulfills the following features: 我必须使用具有以下功能的Java应用程序创建一个jar

  • There are xml data packed in the jar which are read the first time the application is started. jar中打包了xml数据,这些数据是在第一次启动应用程序时读取的。 with every consecutive start of the application the data are loaded from a dynamically created binary file. 在应用程序每次连续启动时,都会从动态创建的二进制文件中加载数据。
  • A customer should not be able to reset the application to its primary state (eg if the binary file gets deleted for some reason, the application should fail to run again and give an error message). 客户应该不能将应用程序重置为其主要状态(例如,如果二进制文件由于某种原因而被删除,则应用程序应该无法再次运行并给出错误消息)。
  • All this should not depend on the os it is running on (which means eg setting a registry entry in windows won't do the job) 所有这些都不应该取决于运行它的操作系统(这意味着例如在Windows中设置注册表项将无法完成任务)

Summarizing I want to prevent a once started application to be reset in order to limit illegitimate reuse of the application. 总结我想防止一次启动的应用程序被重置,以限制应用程序的非法重用。

Now to my ideas on how to accomplish that: 现在我对如何做到这一点的想法:

  • Delete the xml from the jar at the first run (so far I came to the understanding that it is not possible to let an application edit it's own jar. is that true?) 在第一次运行时从jar中删除xml(到目前为止,我了解到不可能让应用程序编辑它自己的jar。这是真的吗?)
  • Set a variable/property/setting/whatever in the jar permanently at the first run (is that possible) 第一次运行时,请在罐子中永久设置变量/属性/设置/任何内容(可以)

Any suggestions/ideas on how to accomplish that? 关于如何实现这一目标的任何建议/想法?

update: 更新:

I did not find a solution for this exact problem, but I found a simple workaround: along with my software I ship a certain file which gets changed after the program is started the first time. 我没有找到解决此确切问题的解决方案,但找到了一个简单的解决方法:我随软件一起提供了一个特定文件,该文件在程序首次启动后会被更改。 of course if someone keeps a copy of the original file he can always replace it and start over. 当然,如果有人保留了原始文件的副本,他可以随时替换并重新开始。

Any user able to delete the binary file, will, with enough time, also be able to revert any changes made in the jar. 任何能够删除二进制文件的用户,只要有足够的时间,也将能够还原jar中所做的任何更改。 When the only existing part of the application is in the hand of the user, you won't able to prevent changes to it. 当应用程序仅有的现有部分由用户掌握时,您将无法阻止对其进行更改。

You can easily just store a backup of the original jar, make a copy, use that for one run, delete, copy the original jar, etc. You would need some sort of mechanism outside the users machine, like an activation server. 您可以轻松地存储原始jar的备份,进行复制,将其用于一次运行,删除,复制原始jar等。您需要在用户计算机外部建立某种机制,例如激活服务器。 The user gets one code to activate an account, and can't use that code again. 用户获得一个激活帐户的代码,无法再使用该代码。

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

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