title: Passing parameters (with spaces) to batch file from java program
body: <p>In my program i want to execute the jar with some parameters with the help of .bat file.</p>
  
  <p><strong>.bat file</strong></p>
  
  <pre><code>%6 -jar %5 -u %1 -p %2 -dbbkp %3 &gt; %4
  </code></pre>
  
  <p><strong>java Program that pass parameters to above .bat file</strong></p>
  
  <pre><code>String jarPath=request.getSession().getServletContext().getRealPath("")+"/OES-SmartClient/OES-SmartClient.jar";
  
  String outputfilepath=request.getSession().getServletContext().getRealPath("")+"/resources/WebFiles/OESFiles/DBBackupStatus.txt";
  
   String jrePath="C:\\Program Files (x86)\\Java\\jre7\\bin\\java";
  
   String batfilePath = request.getSession().getServletContext().getRealPath("")+"/WEB-INF/classes/OESDBBackup.bat";
          String BackupLocation = request.getSession().getServletContext().getRealPath("")+"/WEB-INF/classes/BackupLocation";
  
          batfilePath="\""+batfilePath+"\"";
          jarPath="\""+jarPath+"\"";
          outputfilepath="\""+outputfilepath+"\"";
          BackupLocation="\""+BackupLocation+"\"";
  
      process = Runtime.getRuntime().exec(batfilePath +" "+ dbUser.getUserName()+" "+ dbUser.getPassword()+" "+BackupLocation+" "+outputfilepath+" "+jarPath+" "+jrePath);
  </code></pre>
  
  <p>this above code is for taking database backup.</p>
  
  <p>When i am running this programs its not giving the error but also its fail to take database backup.</p>
  
  <p>when  i am giving BackupLocation like "C:\Sm\"(without space parameter) then its working properly.</p>
  
  <p>Please anyone can suggest me how to pass my parameters with spaces.</p>