🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #1961

Re: Running only one instance of an app

#1961
From: Yonatan Taub
Date: Mon, 23 Jul 2001 18:46
14 lines
1603 bytes
Bind a ServerSocket instance to a specified port at startup.
When you launch the second application. you'll get an Exception which means
that the port is already in use.

You can create a temp file which is created when the application starts and
deleted when it exists.
The file will be used as a flag.
Although this is not "safe" since the user can delete the file (or maybe it
can't because the system will detect that it is in use by another program).
However, if your machine crashes, the next time you start the application,
you'll have to delete the file.

Or, you can do so by checking the running processes in your OS.
This will most likely be achieved by JNI and will lose portabiliy.
Technical Details
Message-ID: <3b5c6247_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!62.112.0.25!newsfeed.online.be!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews
References: <3b5c3b83$1_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,ae9e4c874807e06f
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2001-07-23 11:02:51 PST
Reply-To: "Yonatan Taub" <yonatanta@bashan.co.il>
From: "Yonatan Taub" <yonatanta@bashan.co.il>
Newsgroups: borland.public.jbuilder.java.api
References: <3b5c3b83$1_1@dnews>
Subject: Re: Running only one instance of an app
Date: Mon, 23 Jul 2001 20:46:33 +0200
Lines: 16
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
NNTP-Posting-Host: 212.179.22.2
Message-ID: <3b5c6247_1@dnews>
X-Trace: dnews 995910215 212.179.22.2 (23 Jul 2001 10:43:35 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!62.112.0.25!newsfeed.online.be!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews