title: How to run a shell command through PHP code?
body: <p>I am trying to run a Jar file in the backend of my php code.But I am not getting the desired output to it.There is a jar file which runs in the background and returns the Page Rank of any of the  keyword and Domain given to it.
  I am attaching the code,please suggest me any solution to it,because when I run it on the terminal,it is giving correct output.</p>
  
  <p>Here is the Code :</p>
  
  <pre><code>    &lt;?php
  set_time_limit(0);
  function returnJarPath()
  {
      $jarPath = $_SERVER['DOCUMENT_ROOT'] . "myFolder/tools_new/includes/Rank.jar";
      return $jarPath;
  }
  $jar = returnJarPath();
  $command = "java -jar $jar aspdotnet/microsoft.com";//Passing the Argument to the Jar file.
  
  
  $shellOutput = shell_exec($command);
      print "The Shell Output is : " ; var_dump($shellOutput);print "&lt;br /&gt;";
  exec($command,$executeCommmand);
      print "The Exec returns the value : " ; var_dump($executeCommmand);print "&lt;br /&gt;";
  passthru($command,$passthruCommand);
      print "The Passthru returns the value : " . $passthruCommand. "&lt;br /&gt;";
  ?&gt;
  </code></pre>
  
  <p>I just checked apache's error log and the last error I found was :</p>
  
  <blockquote>
    <p>sh: java: command not found</p>
  </blockquote>
  
  <p>But as I have already said,I have been using the same command through SSH to run the Java command.So there's no such possibility of not having JAVA installed on the server.Please help me out of this mess...</p>