title: Can't call Java program with arguments through PHP
body: <p>I'm trying to connect a Java project with a website. The project is located in "website_folder/data/backend" and at that time, I want to test if the following example works:</p>
  
  <p>[java code]</p>
  
  <pre><code>public static void main(string args[]) {
     if(args[0].equals("5") {
        File f = new File("/location/to/file/result.txt");
        if(!f.exists()) {
           f.createNewFile();
           FileWriter fstream = new FileWriter("/location/to/file/result.txt");
           BufferedWriter out = new BufferedWriter(fstream);
           out.write("It works!");
           out.close();
        }
     }
  }
  </code></pre>
  
  <p>And in the PHP file I have to following command:</p>
  
  <pre><code>&lt;?php
  exec("java -cp /data/backend/Project/build/classes/project/Main.class/ main 5",$output); 
  ?&gt;
  </code></pre>
  
  <p>but nothing happens! I mean, the file isn't created in the directory I have specified in the main method. I have tried to run the .jar file of the project in the PHP command, to pass the argument "5" via a variable, to add to the directory path -in the exec command- this: "i:/xampp/htdocs/website_folder/" (I:\ is the disk drive where I have my virtual server -xampp- installed), but in vain. Am I doing something wrong with the syntax of the command? </p>
  
  <p><strong>Edit:</strong>
  I changed the command to point the .jar file (java -jar /data/backend/Project/dist/Project.jar 5) and the problem is solved.</p>