one cross platform way if doing it is writing a file when you open, and delete it when you close it, but you need to make sure the cleanup is pretty bullet proof.
otherwise you gotta use platform specific APIs I think?
or maybe there is some JVM centric way of doing it...
d
Dominaezzz
03/15/2023, 9:47 AM
Pick a random port and bind to it. 😛
a
Adam Brown
03/19/2023, 9:15 PM
oh or just open your "lock" file for writing, and don't close it, then if you can't open it for writing, you know your other process is open, that's better than deleting it, b/c the "cleanup" is handled by the OS when your process dies.