title: How to handle if there is no default program to launch .pdf file using Runtime.getRuntime().exec("filename ")?
body: <p>I have PDF file and I'm opening it using </p>
  
  <pre><code>Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+filename+".pdf");
  </code></pre>
  
  <p>I'm able to open file properly, but if there are no default programs to open pdf file i need to handle that and show to user</p>
  
  <p>I tried following code </p>
  
  <pre><code>public String openPdfFile(String filename){
      String returnValue="";
      try {
            if(checkIfFileExists(filename+".pdf")){
            Process pPDF= Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+filename+".pdf");
            returnValue=""+pPDF.waitFor();
          }
      }      
  
   } catch (Exception e) {
         return "ERROR";
    }
          return returnValue;
  }
  </code></pre>
  
  <p>it will always return 0 even when there is no default program to launch. How can I achieve this?</p>