Rogan Dawes said:
Alternatively, a native wrapper might be the way to go:
http://www.dobysoft.com/products/nativej/features.html ("single instance"
again)
It seems that native wrappers can be had for multiple platforms, including
Unix. See
http://jgrasp.org/old_site/jgrasp/main.htm, which is
Open-source, so you should be able to find out how it does what it does
The latest sources for our UNIX/Linux (XWindows)
single-instance wrapper are packaged with jGRASP. We
also use native wrappers on Windows and Mac OS X, but
those are not open source.
If you want a fast reaction when the app is already running, a
pure Java solution is troublesome. For example, if jGRASP is
running and the user clicks on an associated source file
externally, that file should pop up fairly instantly. JVM startup
time would cause a noticeable lag on most systems. If startup
time is not an issue though, the usual Java socket method will
be simpler.
A native wrapper can also be used to add other functionality.
On Windows we use it to locate an appropriate JVM;
supply JVM properties at startup - max heap size, user-selected
JVM, antialiasing on/off etc.; display standard out and standard
error from the Java process for diagnostic purposes; allow
a thread dump at any time for diagnostic purposes; and provide
an easy way to kill the Java process if it locks up.