private static String getPid() throws IOException {
        Process p = Runtime.getRuntime().exec("/home/kent/opt/jdk1.6.0_41/bin/jps");
        InputStream in = p.getInputStream();
        List<String> jpsLines = IOUtils.readLines(in);
        for (String line : jpsLines) {
            if (line.contains(HelloPoolSize.class.getSimpleName())) {
                return line.split("\\s")[0];
        throw new IllegalStateException("拿不到pid");

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.