0

I tried to run the batch file from java code, bat file is running but in bat file internally it is calling proxyServer.js file.This .js file is not running. Below is the sample code.

try {
    String path="cmd /c start C:\\AxoneES_Viewers_Integration-2016Q3-SNAPSHOT_201609021003\\AxoneViewers.bat";

    Runtime rn=Runtime.getRuntime();
    Process pr=rn.exec(path);

} catch(IOException ex) {
         System.out.println("Exception Found");
}

As i mentioned internally it is calling .js file where they declared path of the .js file, below is the code , which declared the path. cd viewers\apps\maxq\ node proxyServer.js

while running the bat file it is not able to find the path of .js file and it not running.

Can you help me is there any approach to execute the bat file from java.

Palle
  • 11,511
  • 2
  • 40
  • 61

1 Answers1

0

Try editing the batch file to use absolute file names instead of relative file names. You mentioned your batch file has the lines

cd viewers\apps\maxq\
node proxyServer.js

Change the first line to something like C:\full\path\to\viewers\apps\maxq\. Check out this answer for the difference between absolute and relative file names.

Community
  • 1
  • 1
Daniel O
  • 336
  • 2
  • 3
  • 8
  • I have changed the path in batch file and it is working,but there is condition that i should not change in the batch file.That where i am facing issue for running this batch file – murali avala Oct 26 '16 at 04:24