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:
ROOT_DIR
|.......->com
| |......->somepackage
| |.........->callerClass.java
|
|.......->resource
|........->external.exe
Initially I tried to run the .exe file directly through:
String command = "resources\\external.exe -i input -o putpot";
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(command);
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:
Runtime.getRuntime().exec(new String[]{"cmd.exe", "/c", "resources\\helper.bat"});
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:
@echo off
echo starting process...
external.exe -i input -o output
pause
even if I move .bat file to root and fix its content the problem does not go away. plz plz plz help