private static boolean checkKeytool(String keytoolPath) {
        final SystemCommand nativeCommand = new SystemCommand(null, null);
        final List<String> arguments = new ArrayList<>();
        arguments.add(keytoolPath);
        arguments.add("-J-Xmx128m");
        arguments.add("-help"); // $NON-NLS-1$
        try {
            int status = nativeCommand.run(arguments);
            if (log.isDebugEnabled()) {
                log.debug("checkKeyTool:status=" + status);
                log.debug(nativeCommand.getOutResult());
            }
            /*
             * Some implementations of keytool return status 1 for -help
             * MacOS/Java 7 returns 2 if it cannot find keytool
             */
            return status == 0 || status == 1; // TODO this is rather fragile
        } catch (IOException ioe) {
            log.info("Exception checking for keytool existence, will return false, try another way.");
            log.debug("Exception is: ", ioe);
            return false;
        } catch (InterruptedException e) { // NOSONAR
            log.error("Command was interrupted\n" + nativeCommand.getOutResult(), e);
            Thread.currentThread().interrupt();
            return false;
        } catch (TimeoutException e) { // NOSONAR
            log.info("Timeout reached while checking for keytool existence, will return false, try another way.", e);
            return false;
        }
    }
@Test
    public void testCheckKeytool() throws Exception {
        SystemCommand sc = new SystemCommand(null, null);
        List<String> arguments = new ArrayList<>();
        arguments.add("xyzqwas"); // should not exist
        Assertions.assertThrows(IOException.class, () -> {
            int status = sc.run(arguments);
            if (status == 0 || status == 1) {
                fail("Missing executable should produce exit code of 0 or 1. Actual code is " + status);
            }
        });
    }