I was making an application in Java and I was wondering if there was any way to know if when I run this application from the shortcut, it detects that it is already running and opens that process for me as it happens with the Spotify desktop application.
I have found a "homemade" method to know if it is already running; I save the current time with Java.util.Calendar.getTimeInMillis()
in a notepad every x seconds, if when trying to open the application from a direct access the time saved in the txt is less than x it means it is running and it would not open another copy. With this I make sure that it can only be opened once, but I would like it not only to be able to do that but also to find that process and send it to the front.