title: Get path of Java application that launched the executable
body: <p>I am trying to validate that only our Java application has launched an inside-included executable. To achieve this, I thought of having a list of valid known SHA2 hashes (of the Java application) on our server and the executable will first check if the application's hash it was launched from is on that list.</p>
  
  <p>So far, everything is working. The hashing, client-server communication etc. Except I have stumbled at the last hurdle. I am unable to get the path of the Java application from the executable. </p>
  
  <p>I thought I could simply do this:</p>
  
  <pre><code>pid_t jarpid = getppid();
  
  // Got from online
  int get_exe(pid_t pid, char* buf, size_t bufsize) {
      char path[64];
      sprintf(path, "/proc/%d/exe", pid);
      return readlink(path, buf, bufsize);
  }
  </code></pre>
  
  <p>However this points to /usr/lib/jvm/java-8-oracle/jre/bin/java and not the running Java Application. I do use the ProcessBuilder in the application to launch the executable.</p>
  
  <p>So my question is, how can I get the applications path that launched the executable. Is it even possible? I cannot provide the executable with arguments, as that would be too easy to reverse engineer.</p>