Systray in Java - Restricting to one instance

G

Gopuram

Hi,
I am looking for information for restricting my systray icon to one
instance (Should not create another Systray Icon on launching the
application again or starting the service...).
Any help or pointers is appreciated.

Thanks,
Gopuram
 
R

Rogan Dawes

Andrew said:
It sounds like you might be able to use the same technique
often used to ensure a single instance of an application.
Grab a socket, and check for it..
<http://www.google.com/search?hl=en&lr=&c2coff=1&q="single+instance"+socket>

HTH

For what it is worth, you may want to ensure that you only listen to
localhost, rather than making a network socket accessible to everyone on
the internet . . . . The best part of the socket solution is that you
can use it to associate data file extensions with your app, and instruct
the currently running version (over the socket) to open the file passed
as the first parameter . . .

Also check
http://java.sun.com/j2se/1.5.0/docs/guide/javaws/enhancements-1.5.0.html
(search for "single instance")

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
.. . . .

Regards,

Rogan
 
L

Larry Barowski

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top