Hi all
how can i check if my .jar is runing already?
for example if the user open my .jar and already is runing, show a msg, this is runing you cant open another.
When the .jar first starts up, check for a file called "running.txt". If it doesn't exist, create it. If it does exist, post a message saying "can't have two instances of this app running" and then shutdown. When the user closes the app, don't forget to delete "running.txt".
any other way? for example check on taskmanager (system process) if this is running and show a msg?
i already have this ideia of txt file, but i remember the user can use ALT + F4 and i cant delete txt in this case
All java processes show up as java.exe in the Task Manager. That won't be of any use to you. Erel had the idea to open up a Socket on (say) port 12345. Attempting to open a socket on this port will fail if another program has already opened a socket on that port. Ideally, the port should be released when the process ends, regardless of how it ends, but I would test that to make sure.
Build an installer for your app with B4JPackager and then the file will be a regular executable.
Check the running processes with jShell (tasklist on Windows / ps on Mac and linux).
TempPath = Utils.GetCanonicalPath (File.DirTemp)
lbInfo.Text = "Deleting old database"
If File.Exists (TempPath, "Databs.db") Then
If Not (File.Delete (TempPath, "Databs.db")) Then
msgbox.show ("Databs.db is in use. Stopping system.")
ExitApplication
end If
end If
CallSubDelayed (Me, "IniSql") 'create and initialize the file Databs.db