private void runKillCommand(String killArg) throws Exception { try { long pid = panelProcesses.getSelectedProcessId(); if (pid > -1) { String command = "kill " + killArg + " " + Long.toString(pid); try { if ((killArg.equals("-TERM") || killArg.equals("-KILL")) && preference.isAlertBeforeKillingProcess()) { int result = JOptionPane.showConfirmDialog( this, "Are you sure you want to terminate this process?", "Confirm", JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { sshSession.getStandardOutput(command); } } else { sshSession.getStandardOutput(command); } } catch (Exception e) { JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } updatePreference(); } } catch (Exception e) { e.printStackTrace(); throw e; } }