双击jar时避免多个app实例 [英] Avoiding multiple app instances when double clicking a jar

查看:146
本文介绍了双击jar时避免多个app实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个只有一个实例的应用。即使用户双击一次jar 2次,我希望只有1个jframe实例。

有人可以给我任何关于我应该怎么做的建议吗?

谢谢。

I want to make an app, that has just one instance. Even if the user double clicks a jar 2 times, I want there just to be 1 jframe instance.
Could someone give me any suggestions on how I should do this?
Thanks.

推荐答案

有许多系统,但最可靠的是始终创建应用程序锁定的文件。创建/访问锁定文件的任何进一步试验都将失败,这意味着实例已经在运行时持有锁。

查看 here [ ^ ]以获取一些建议。顺便说一句,你可以通过谷歌搜索找到很多关于这个主题的文档...

如果你对混合编程很有帮助,你可以使用一些C / C ++技术(即互斥方法)。
There are many systems, but the most reliable is always the creation of a file that the application locks. Any further trials to create/access the locked file will fail meaning that an instance is already running holding the lock.
Look here[^] for some suggestions. BTW you can find a lot of docs on the subject simply googling...
If you are confortable with mixed programming you can use some C/C++ techniques (i.e. mutex method).


这篇关于双击jar时避免多个app实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆