0

I am creating a batch file from Java which is deployed in a Linux machine and moved from Linux to Windows using Samba.

We want the batch file to be triggered from Java. Can you please highlight some steps?

I cannot use below command as it will use Linux run time:

Runtime.getRuntime().exec("cmd /c start buildFile.bat");

Any suggestions?

null
  • 2,060
  • 3
  • 23
  • 42
Wafa Saba
  • 101
  • 1
  • 9

2 Answers2

0

You can execute processes from Java on Linux as described here. The process is executed from the operationg system and depends on the operating system. You could rewrite your buildFile.bat as a linux shell script on execute it from you Java program.

Community
  • 1
  • 1
remipod
  • 11,269
  • 1
  • 22
  • 25
  • We need batch file to be triggered in windows by java in linux. – Wafa Saba Apr 30 '15 at 21:58
  • You can trigger a process from java on the local machine. The operating system of the local machine is responsible to executes the process. Linux cannot run Windows Batch files natively, but you may use Wine on linux. Wine emulates many Windows functionality and may help you. Have a look at this tutorial: http://www.linux.org/threads/running-windows-batch-files-on-linux.7610/ – remipod May 01 '15 at 07:45
  • In my humble opinion I would not run Winndows Batch files on Linux because it is too much trouble. For instance, the directory path concept is different. Personally, I would prefer to to rewrite the batch file as a linux script but I don't know your specifics. It seems you can't take that approach. – remipod May 01 '15 at 07:50
0

I created Batch file in Windows using Samba from Linux machine and let windows scheduler handle running batch file. Problem solved :)

Wafa Saba
  • 101
  • 1
  • 9