MacOS – Java application won’t force quit, prevents shutdown

javamacosterminal

I think there might be an issue on El Capitan with Java applications force quitting, because I've seen multiple people talk about similar problems to this with no actual solutions presented.

I've been writing applications in eclipse, and one application of mine occasionally has an issue where the program ends, yet the java icon stays in the dock.

I can right-click the icon and tell it to Force Quit, but this has no effect. If I open the force quit window with command-option-escape, the application shows up, but again, force quitting does nothing. The application does not show up in Activity Monitor, so I can't end the process.

Shut-down is impossible while this application remains open. I have to force shutdown and reboot in order to get rid of this program.

I can run "killall Dock" from Terminal, which makes the application disappear from the dock… BUT, the application still shows up in the force quit window, and it still cannot be force quit from there. Furthermore, a terminal-looking window labeled "java" appears after running this command. This new application cannot be force quit through right-click, does NOT show up in the force quit window, and doesn't show up in Activity Monitor either. Shutting down normally is still impossible.

I've seen various other topics where people had this issue with certain java programs under El Capitan, but most had very little detail, and none had a true fix to the issue.

Does anyone know why this happens? How to prevent it from happening in my programs? How to truly force quit applications like these?

Best Answer

You should be able to use Terminal to kill the process, if you know it's name with the following commands.

  1. Find the process identifier (PID). Substitute [your process here] with the name of your process.

    ps -e | grep "[your process here]"

  2. The PID will be on the left most column. Here is example output:

    7642 ttys001 0:00.00 grep

  3. Now type, into terminal, substituting [PID] for your process' PID

    kill -9 [PID]

  4. Re-run step 2. If the process is no longer there, you've successfully killed it.


Brief explanation of steps:

  1. ps gives information of running processes. In this case, we used grep to filter out the specific process we were looking for.

  2. The format of ps's columns is PID/TTY/TIME/CMD. The field we are interested in is PID.

  3. kill -9 sends the undeniable SIGKILL signal to the process specified in PID. This signal cannot be ignored by any process and is hence promptly terminated, no ifs or buts.

  4. As mentioned above, ps gives information of running processes. If your process is no longer in ps's output, it's no longer running.


I would recommend fixing that weird exit bug of yours.

killall Dock only kills the Dock process, which forces an update of programs running. This may make your application disappear from the dock, but the app may still be running in the background.

Personally, I don't have any problems with Java apps in El Capitan. I'm no Java expert so I probably shouldn't suggest any reasons for this unexpected behavior. Have you tried filing a bug report?