Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Constrain a single instance of an SWT application!
Constrain a single instance of an SWT application! [message #449348] Sat, 22 January 2005 22:32 Go to next message
Eclipse UserFriend
Originally posted by: shaffin.email.uophx.edu

This is a multi-part message in MIME format.

------=_NextPart_000_01B1_01C500A8.5755E580
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello All,

I have an SWT application and wanted to know if there any simple =
mechanism of identifying an already running instance of the application. =
I only want a single instance of my application to run and not allow the =
user to launch another instance of my application. Any thoughts/ideas??

Shaffin.

------=_NextPart_000_01B1_01C500A8.5755E580
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2180" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Hello All,</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I have an SWT application and wanted to know if =
there any=20
simple mechanism of identifying an already running instance of the =
application.=20
I only want a single instance of my application to run and not allow the =
user to=20
launch another instance of my application. Any=20
thoughts/ideas??</FONT></DIV><FONT size=3D2>
<DIV><BR>Shaffin.</DIV>
<DIV></FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_01B1_01C500A8.5755E580--
Re: Constrain a single instance of an SWT application! [message #449446 is a reply to message #449348] Mon, 24 January 2005 17:56 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.

------=_NextPart_000_0082_01C50214.2BF560B0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

On Windows, many native applications use the operating system call =
FindWindow() to see whether a particular window class has been =
registered and a window has been created of that class.

"SHAFFIN BHANJI" <shaffin@email.uophx.edu> wrote in message =
news:csuk9t$3vr$1@www.eclipse.org...
Hello All,

I have an SWT application and wanted to know if there any simple =
mechanism of identifying an already running instance of the application. =
I only want a single instance of my application to run and not allow the =
user to launch another instance of my application. Any thoughts/ideas??

Shaffin.

------=_NextPart_000_0082_01C50214.2BF560B0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>On Windows, many native applications =
use the=20
operating system call FindWindow() to see whether a particular window =
class has=20
been registered and a window has been created of that =
class.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>"SHAFFIN BHANJI" &lt;<A=20
href=3D"mailto:shaffin@email.uophx.edu">shaffin@email.uophx.edu</A>&gt; =
wrote in=20
message <A=20
href=3D"news:csuk9t$3vr$1@www.eclipse.org">news:csuk9t$3vr$1@www.eclipse.=
org</A>...</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV><FONT size=3D2>Hello All,</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I have an SWT application and wanted to know if =
there any=20
simple mechanism of identifying an already running instance of the=20
application. I only want a single instance of my application to run =
and not=20
allow the user to launch another instance of my application. Any=20
thoughts/ideas??</FONT></DIV><FONT size=3D2>
<DIV><BR>Shaffin.</DIV>
<DIV></FONT>&nbsp;</DIV></BLOCKQUOTE></BODY></HTML >

------=_NextPart_000_0082_01C50214.2BF560B0--
Re: Constrain a single instance of an SWT application! [message #449453 is a reply to message #449348] Mon, 24 January 2005 18:40 Go to previous message
L.M. Fridael is currently offline L.M. FridaelFriend
Messages: 16
Registered: July 2009
Junior Member
SHAFFIN BHANJI wrote:
> I have an SWT application and wanted to know if there any simple
> mechanism of identifying an already running instance of the application.
> I only want a single instance of my application to run and not allow the
> user to launch another instance of my application. Any thoughts/ideas??

A cross-platform solution is to let your app create a server socket on
some unused port (i.e. a port not used by major protocols like FTP,
HTTP, POP3, etc). If the server socket can't be created, it means
another instance of the app is already active. (You could then send an
"activation" message to the server socket.)

On Windows I usually create native EXE launchers that instantiate the
JVM through JNI invocation. The EXE creates a Win32 Mutex to prevent
multiple instances from being started. Obviously, this is a
Win32-specific solution.


Regards
-Laurens
Previous Topic:Colors on linux/gtk
Next Topic:New Platform Browser from Browser Widget
Goto Forum:
  


Current Time: Thu Apr 25 12:52:52 GMT 2024

Powered by FUDForum. Page generated in 0.02950 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top