Search code examples
javaphpappletsingle-instance

Limit Java Applet to only one instance


I have been using Stackoverflow for a while to find solutions to my programming questions, but for the current question I haven't found a useful solution. So I joined up.

What would be a good solution to limit a Java applet to only one instance. I'm using php to serve the applet to the end user, so that would be an option.

But I'm much more interested if I can limit the execution of an Java Applet through the Applet itself. I'm pretty new to Java so I don't really know where to start looking for a construction like that.

Any suggestions would be appreciated.

As a side note, " javascript to launch only ONE window for a Java applet with a given URL" would be a solution. Although I'm embedding the applet into the application I'm building and I'm not really keen on a popup serving the applet.

Sincerely, AltWouss

Edit:
To clarify the instance limit. I would like to have only one applet loaded per machine.


Solution

  • Why don't you start a SocketServer on a well known port for your applet ?

    If opening that SocketServer, it may be due to the fact that another one is already running. Then, you can display a message telling so.