Hi,

I am using Selenium Grid and running my test cases on remote machine. And i am also using Screen recorder to record video for my test. When i start Screen recorder, it only starts in the hub machine (my machine). So i thought to run the Screen recorder on remote machine by running a batch file using my Selenium Java code.

So, now I want to run a batch file in a remote machine using JAVA to start screen recorder application to record test run in that remote machine.. Could anyone advise, how this is possible in JAVA code.

Regards
Manish

Part of the design of Java is that it runs in a virtual machine and everything that a Java program (applets, etc.) does happens within that virtual machine. This means that a Java program should not be able to run another application that is not also part of the same virtual machine, and definitely not on the host computer's operating system. This was a deliberate design decision and security consideration by the people at Sun Microsystems when they were first creating the Java system and, as far as I know, has not changed.

Mind you, you could create a script or batch on the remote system that launches the screen recorder and the Java program, but it has to be run on the remote machine's operating system, seperate from the Java environment.

Edited 4 Years Ago by Nutster: grammar fix.

Yes, it is entirely possible. Sorry Nutster, your answer is completely wrong.
Java has the ability to run external processes. In older versions of Java it used the Runtime class, modern versions use ProcessBuilder. You can start an external process and pipe its standard input and output and error streams from/to your Java program.
This works 100% from Java applications, but needs appropriate security settings to run from an applet. (You can also run scripts in many scripting languages from your Java code and share variables with them.)
Google Java ProcessBuilder for details and examples.

This article has been dead for over six months. Start a new discussion instead.