-1

I am doing simple rmi application.since it has server I want to lock java application when it is ideal. Is there any convent way to apply lock system in java

sAaNu
  • 1,428
  • 7
  • 21
  • 46
  • 4
    What do you mean by "lock the system"? – atk Jun 17 '11 at 18:08
  • There must be some Skeleton Key API ;-) – Olaf Jun 17 '11 at 18:20
  • I mean lock java application so that othet cant use that application evem it is running ......and prompt for password for unlock – sAaNu Jun 17 '11 at 18:44
  • Since you speak of client/server: are you trying to prevent multiple clients from running at the same time, on different computers? – atk Jun 17 '11 at 20:43

2 Answers2

0

There are two approaches I can think of.

  1. If it's all stand alone applications on the same computer, just create an empty file on disk when you start running, and any other instance attempting to start should look for the same file and if it exists, exit.

  2. If you can't share a "lock" file described above then can you set a record in a database table? All instances could check for the record existing (timestamp?) and then act accordingly.

Either way you need a central shared resource to act as a lock

Brad
  • 15,186
  • 11
  • 60
  • 74
0

I'm not sure if I understand your question. If it's about running single instance of an application, check out this: How to implement a single instance Java application?

Otherwise, if it's related to security, you should precise what are you trying to achieve.

Community
  • 1
  • 1
genobis
  • 1,081
  • 9
  • 13