public static Long getPid() {
    String name = ManagementFactory.getRuntimeMXBean().getName();
    List<String> nameParts = Splitter.on('@').splitToList(name);
    if (nameParts.size() == 2) { // 12345@somewhere
      try {
        return Long.parseLong(Iterators.get(nameParts.iterator(), 0));
      } catch (NumberFormatException ex) {
        LOG.warn("Failed to get PID from [" + name + "]", ex);
      }
    } else {
      LOG.warn("Don't know how to get PID from [" + name + "]");
    }
    return null;
  }
Returns PID of the current process, if it can be extracted from JVM name, or null.
hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientIdGenerator.java