1

If I have one desktop application written in Java with swing or applet, Which have installed in Any operating System desktop either Windows or Unix. Now If any user will open first time (like to double click on desktop shortcut in windows desktop) then it should open first window but when user will try to open same application second time it should populate same windows means it should not open second time with other windows. Example: Like Outlook works in a desktop. How to achieve this with pure core java without using any configuration file and DB configuration?

MKumar
  • 79
  • 2
  • 6
  • 3
    Without any outside configuration? Good luck. Only way i can think of right off would be to try to bind a socket to a specific address/port...but then you need to be able to specify which one. – cHao Sep 08 '14 at 05:39

1 Answers1

3

You'll have to use the file system, and maintain a lock file, Or use some IPC mechanism (perhaps abuse the network stack by binding a local port?) If you want the first instance to be aware of the second instance, you'll also need to do IPC communication to facilitate that. Different instances of java run in separate JVMs, while Windows application accomplish that feature via an OS-provided mechanism (instance handles).

BadZen
  • 4,083
  • 2
  • 25
  • 48