I need to connect to Linux using java code from my Windows machine and execute a linux command. Following is the code I am using:
I am getting following error while executing this code:
java.io.IOException: Cannot run program "grep": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at macys.RunCommand.main(RunCommand.java:45)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 5 more
exception happened - here's what I know:
I think it is not executing linux command because it is still in Windows operating system. When I include the following code in my program, i can see that is still in Windows.
Output: "I am windows"
I need to connect to Linux and execute a Linux command from Windows. How do I do it using Java code? Can somebody please help me out in this asap?