B4J Question Only one instance of an app

Bruce Axtens

Active Member
Licensed User
Longtime User
How do I make sure that there's only ever one instance of my B4J app running.VB6 had
The PrevInstance property in Visual Basic 6.0 determines if an instance of the application is already running. Typically you call PrevInstance on application startup and abort the application if it returns true.
Is there anything equivalent in B4J?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
If you are only targeting Windows then you can use Launch4j to convert the jar file to an exe file and also allow a single instance of it:

SS-2015-03-03_08.32.36.png


A cross platform solution is more difficult. You can open a specific port with ServerSocket and if it fails then the app is already open.
 
Upvote 0

Bruce Axtens

Active Member
Licensed User
Longtime User
Thanks, Erel. Just what I'm looking for.
 
Upvote 0
Top