protected static void checkJavaVersion(final PrintStream logger, String javaCommand,
                                    final BufferedReader r)
            throws IOException {
        String line;
        Pattern p = Pattern.compile("(?i)(?:java|openjdk) version \"([0-9.]+).*\".*");
        while (null != (line = r.readLine())) {
            Matcher m = p.matcher(line);
            if (m.matches()) {
                final String versionStr = m.group(1);
                logger.println(Messages.ComputerLauncher_JavaVersionResult(javaCommand, versionStr));
                try {
                    if (new VersionNumber(versionStr).isOlderThan(new VersionNumber("1.8"))) {
                        throw new IOException(Messages
                                .ComputerLauncher_NoJavaFound(line));
                    }
                } catch (NumberFormatException x) {
                    throw new IOException(Messages.ComputerLauncher_NoJavaFound(line), x);
                }
                return;
            }
        }
        logger.println(Messages.ComputerLauncher_UnknownJavaVersion(javaCommand));
        throw new IOException(Messages.ComputerLauncher_UnknownJavaVersion(javaCommand));
    }
@Test public void j2sdk4() {
        assertThrows(
            IOException.class,
            () ->
                ComputerLauncher.checkJavaVersion(
                    new PrintStream(OutputStream.nullOutputStream()),
                    "-",
                    new BufferedReader(
                        new StringReader(
                            "java version \"1.4.2_19\"\n"
                                + "Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_19-b04)\n"
                                + "Java HotSpot(TM) Client VM (build 1.4.2_19-b04, mixed mode)\n"))));
    }