title: changing the working-directory of command from java
body: <p>I need to execute a .exe file from a function in one of the packages I have in my java project. now the working directory is the root directory of the project for java but the .exe file in sub-directories of my project. here is how the project is organized:</p>
  
  <pre><code>ROOT_DIR
  |.......-&gt;com
  |         |......-&gt;somepackage
  |                 |.........-&gt;callerClass.java
  |
  |.......-&gt;resource
           |........-&gt;external.exe
  </code></pre>
  
  <p>Initially I tried to run the .exe file directly through:</p>
  
  <pre><code>String command = "resources\\external.exe  -i input -o putpot";
  Runtime rt = Runtime.getRuntime();
  Process pr = rt.exec(command);
  </code></pre>
  
  <p>but the problem is external .exe needs to access some files in it's own directory and keeps thinking root directory is its directory. I even tried to use .bat file to solve the problem but the same issue rises:</p>
  
  <pre><code>Runtime.getRuntime().exec(new String[]{"cmd.exe", "/c", "resources\\helper.bat"});
  </code></pre>
  
  <p>and the .bat file is in the same directory as the .exe file but the same issue happens. here is the content of the .bat file:</p>
  
  <pre><code>@echo off
  echo starting process...
  
  external.exe -i input -o output
  
  pause
  </code></pre>
  
  <p>even if I move .bat file to root and fix its content the problem does not go away. plz plz plz help</p>