The answer which the other use shown and marked as duplicate still doesn't work.
Instead of marking it duplicate and refusing the question it would be better to answer it and make sure that the asker of the question that is me is satisfied with the answer.
I want to run a Batch file whose name is Test.bat and which is present in the same directory where this java file would be executed and the directory string is stored in dir but I have tried the following code to call it but it is not working.
Please someone help me with this.
public static void main(String[] args) {
String dir = System.getProperty("user.dir");
dir = dir.replace('\\','/');
System.out.println("current dir = " + dir);
ProcessBuilder batch = new ProcessBuilder("Test.bat");
try {
batch.start();
}
catch (IOException e)
{
e.printStackTrace();
}
}