title: run shell command from java
body: <p>I am working on an application an have an issue about running shell command from java application. here is the code:</p>
  
  <pre><code>public String execRuntime(String cmd) {
  
          Process proc = null;
          int inBuffer, errBuffer;
          int result = 0;
          StringBuffer outputReport = new StringBuffer();
          StringBuffer errorBuffer = new StringBuffer();
  
          try {
              proc = Runtime.getRuntime().exec(cmd);
          } catch (IOException e) {
              return "";
          }
          try {
              response.status = 1;
              result = proc.waitFor();
          } catch (InterruptedException e) {
              return "";
          }
          if (proc != null &amp;&amp; null != proc.getInputStream()) {
              InputStream is = proc.getInputStream();
              InputStream es = proc.getErrorStream();
              OutputStream os = proc.getOutputStream();
  
              try {
                  while ((inBuffer = is.read()) != -1) {
                      outputReport.append((char) inBuffer);
                  }
  
                  while ((errBuffer = es.read()) != -1) {
                      errorBuffer.append((char) errBuffer);
                  }
  
              } catch (IOException e) {
                  return "";
              }
              try {
                  is.close();
                  is = null;
                  es.close();
                  es = null;
                  os.close();
                  os = null;
              } catch (IOException e) {
                  return "";
              }
  
              proc.destroy();
              proc = null;
          }
  
  
          if (errorBuffer.length() &gt; 0) {
              logger
                      .error("could not finish execution because of error(s).");
              logger.error("*** Error : " + errorBuffer.toString());
              return "";
          }
  
  
          return outputReport.toString();
      }
  </code></pre>
  
  <p>but when i try to exec command like :</p>
  
  <pre><code>/export/home/test/myapp -T "some argument"
  </code></pre>
  
  <p>myapp reads <code>"some argument"</code>  as two seperated arguments.but I want to read <code>"some argument"</code> as only a argument. <strong>when i directly run this command from terminal, it executed successfully.</strong> I tried <code>'"some argument"'</code> ,<code>""some argument""</code> , <code>"some\ argument"</code>  but did not work for me. how can i read this argument as one argument.</p>