I am running a Java Appium code where I want to start my emulator programmatically for which I am using the Process builder.
Caused by: java.io.IOException: CreateProcess error=5, Access is denied
Here is the code snippet:
import java.io.File; import java.io.IOException;
public class EmulatorRunner { public static void main(String[] args) { String emulatorPath = "C:\Users\nithyashri.raov\AppData\Local\Android\Sdk\emulator";
// You might need to adjust the emulator name and other parameters based on your setup
String[] command = {emulatorPath, "-avd", "your_avd_name"};
try {
ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.directory(new File(emulatorPath).getParentFile());
Process process = processBuilder.start();
// Optional: You can capture the output of the emulator if needed
// InputStream inputStream = process.getInputStream();
// BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
// String line;
// while ((line = reader.readLine()) != null) {
// System.out.println(line);
// }
} catch (IOException e) {
e.printStackTrace();
}
}
}