Self-inflicted killing utility
Interesting little plot twist in a Java program.

First up, tryNow() is dead code, it's not used, get rid of it, it makes the rest of the class harder to understand by putting red-herrings in the code.

If it is really used somewhere else in your code (it is public static), then it should be moved out of this class in to a more usefully named location.... and it has other issues too, which I will ignore... except for .... never extend Thread directly, use Runnable ....

Next up, you should ensure you are using Java 9.x or newer, and then use the more convenient ProcessHandle API for getting your current processID

This reduces the code:


static int obtainPid() throws CantKillMeException {
    try {
        java.lang.management.RuntimeMXBean runtime = java.lang.management.ManagementFactory.getRuntimeMXBean();
        java.lang.reflect.Field jvm = runtime.getClass().getDeclaredField("jvm");
        jvm.setAccessible(true);
        sun.management.VMManagement mgmt = (sun.management.VMManagement) jvm.get(runtime);
        java.lang.reflect.Method pid_method = mgmt.getClass().getDeclaredMethod("getProcessId");
        pid_method.setAccessible(true);
        int pid = (Integer) pid_method.invoke(mgmt);
        return pid;
    } catch (IllegalAccessException | java.lang.reflect.InvocationTargetException | NoSuchMethodException |
NoSuchFieldException e) {
        throw new CantKillMeException("Cant obtain pid", e);
    }
}



to just:

static int obtainPid() throws CantKillMeException {
    try {
       return ProcessHandle.current().pid();
    } catch (SecurityException e) {
        throw new CantKillMeException("Cant obtain pid", e);
    }
}


Although you don't want to do a System.exit(0) I would still plan it as a backup...

You have 


static void executeCommand(String command) throws CantKillMeException {
    try {
        Process process = Runtime.getRuntime().exec(command);
        process.waitFor();
    } catch (java.io.IOException | InterruptedException e) {
        throw new CantKillMeException("Cant execute command " + command, e);
    }
  }



which anticipates exceptions on something that should terminate the process....

I would instead log the exception (actually, catch any Throwable), and exit.... within a finally-block - I would do that in the now() method:

public static void now() throws CantKillMeException {
    try {
        int pid = obtainPid();
        String command = getCommand(pid);
        executeCommand(command);
    } catch (Throwable t) {
        System.out.println(t);
    } finally {
        System.exit(1);
    }
}


You can choose a different (improved) logging mechanism.