title: Runtime Exec changing path
body: <p>I need to launch another Java program at runtime, this is my code</p>
  
  <pre><code>  try {
                                   String cmd2 = "java -jar c:\\test\\deploy\\framework_e_app.jar";
  
                                   Process p = Runtime.getRuntime().exec(cmd2);  
                                   BufferedReader in = new BufferedReader(  
                                                       new InputStreamReader(p.getInputStream()));  
                                   String line = null;  
                                   while ((line = in.readLine()) != null) {  
                                           System.out.print("&lt;STDOUT&gt;");
                                       System.out.print(line);
                                       System.out.println("&lt;/STDOUT&gt;");
                                   }  
  
                                   InputStream stderr = p.getErrorStream();
                                   InputStreamReader isr = new InputStreamReader(stderr);
                                   BufferedReader br = new BufferedReader(isr);
                                   String line2 = null;
                                   System.out.print("&lt;STDERROR&gt;");
                                   while ( (line2 = br.readLine()) != null)
                                       System.out.print(line2);
                                   System.out.println("&lt;/STDERROR&gt;");
  
                           } catch (IOException e) {  
                               e.printStackTrace();  
                           }
  </code></pre>
  
  <p>This is the only way i got it working, but it is annoying because it search configuration files in the current path.</p>
  
  <p>I tried using this as cmd2:</p>
  
  <pre><code>String[] cmd2 = new String[4];
  cmd2[0] = "cmd";
  cmd2[1] = "/C";
  cmd2[2] = "cd test\\deploy";
  cmd2[3] = "java -jar framework_e_app.jar";
  </code></pre>
  
  <p><strong>I couldn't get working the directory change.</strong> What's the right syntax? (Im in a Windows environment, obviously).</p>