title: Java to play audio file through the commandline
body: <p>I would like to play a sound file using java through the command line.</p>
  
  <p>so far I have succeded at listing the contents of a directory, but cannot play a wav file </p>
  
  <p><strong>code to list the content of a directory</strong></p>
  
  <pre><code>Process p = Runtime.getRuntime().exec(new String[]{"/bin/bash","-c","ls"});
                          BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
                          String line=null;
                          while((line=input.readLine()) != null) {
                              System.out.println(line);
                          }
                          int exitVal = p.waitFor();
                          System.out.println("Exited with error code "+exitVal); 
  </code></pre>
  
  <p><strong>code to play a wav file, this doesn't work</strong></p>
  
  <pre><code> Process p = Runtime.getRuntime().exec(new String[]{"/usr/bin/aplay","~/javafx/examples/PrayerTime/dist/police_s.wav"});
                              BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
                              String line=null;
                              while((line=input.readLine()) != null) {
                                  System.out.println(line);
                              }
                              int exitVal = p.waitFor();
                              System.out.println("Exited with error code "+exitVal); 
  </code></pre>
  
  <p><strong>I get the following error</strong></p>
  
  <pre><code>Exited with error code 1
  </code></pre>