I want to prevent the user from running my java application multiple times in parallel.
To prevent this, I have created a lock file when am opening the application,
You could write the process id of the process that created the lock file into the file. When you encounter an existing lock file, you do not just quit, but you check if the process with that id is still alive. If not, you can go ahead.