code: public static String getPID() throws IOException{
          String pid = System.getProperty("pid"); //NOI18N
          if(pid==null){
              String command;
              if(OS.get().isUnix())
                  command = "echo $$ $PPID";
              else{
                  // getpids.exe is taken from http://www.scheibli.com/projects/getpids/index.html (GPL)
                  File tempFile = File.createTempFile("getpids", "exe"); //NOI18N
  
                  // extract the embedded getpids.exe file from the jar and save it to above file
                  IOUtil.pump(RuntimeUtil.class.getResourceAsStream("getpids.exe"), new FileOutputStream(tempFile), true, true); //NOI18N
                  command = tempFile.getAbsolutePath();
                  tempFile.deleteOnExit();
              }
              StringTokenizer stok = new StringTokenizer(runCommand(command));
              stok.nextToken(); // this is pid of the process we spanned
              pid = stok.nextToken();
              System.setProperty("pid", pid); //NOI18N
          }
          return pid;
      }
docs: Returns the PID of the current process. The PID will also be saved in system property <code>"pid"</code>
  
  @return PID of current progress
  
  @throws IOException If an I/O error occurs