I need something to check if another instance of the same java program is already running on Linux when the program start. If yes, the program need to exit to avoid two services running at the same time.
Does anybody know the best practise?
Thanks
Do it like the most linux programs are doing.
Put a file with your pid into /var/run/[Program].pid or/var/run/[Program]/pid
Getting list of processes in Linux can be done in many ways. For something specific to Java, check this thread: List of Java processes (on Stackoverflow)
You will possibly get your answer there.