I know the commands to get the browser version of Edge, Firefox and Chrome in mac using command line which is working properly on my system.
Edge=/Applications/"Microsoft Edge.app"/Contents/MacOS/"Microsoft Edge" -version
FireFox=/Applications/Firefox.app/Contents/MacOS/firefox -v
Chrome=/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version
Chrome1=/Applications/"Google Chrome.app"/Contents/MacOS/"Google Chrome" --version
When I try with Firefox it successfully returns me the Firefox version. but when I try for the Edge or the chrome it throws error in the java program.
Cannot run program "/Application/"Google" error=2 no such file or directory
I tried the escaping the query as /Applications/\"Microsoft Edge.app\"/Contents/MacOS/\"Microsoft Edge\" -version
.I am printing the same before passing as a query and I am exactly getting the same query which works if I directly copy paste it on the terminal.
below is the code snippet
Am I missing something?
String line;
Process process;
String msEdgeVersion = null;
/*process = Runtime.getRuntime().exec("/Applications/Firefox.app/Contents/MacOS/firefox -v");*/
process = Runtime.getRuntime().exec(/Applications/"Microsoft Edge.app"/Contents/MacOS/"Microsoft Edge" -version);
// process = Runtime.getRuntime().exec("where notepad");
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
while ((line = br.readLine()) != null) {
if (!StringUtils.isBlank(line)) {
msEdgeVersion = line;
System.out.println(line);
}
}
process.waitFor();
process.destroy();