Reputation: 2078
If I use the Windows run utility (Windows Key + R), and I type in "chrome.exe" it launches Chrome. Same thing for other applications that have their path in the PATH variable, of course.
However, in java if I try this:
Runtime.getRuntime().exec("chrome.exe");
It doesn't work. It only works if I use the full path. How can I make it execute chrome without needing the entire path? Thank you!
Upvotes: 1
Views: 372
Reputation: 9862
use cmd/c
.you can use cmd option to specify that you are running a cmd command otherwise java try to run a chorm.exe from the folder where your .class exist so it will throw a error.
Runtime.getRuntime().exec("cmd /c start chrome.exe");
Upvotes: 1