I am getting Exception:
in thread "main" java.lang.IllegalStateException:The path to the 
 driver executable must be set by the webdriver.chrome.driver 
 system property;
 for more information, 
  see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. 
  The latest version can be downloaded from 
  http://chromedriver.storage.googleapis.com/index.html
    at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
    at org.openqa.selenium.chrome.ChromeDriverService.access$0(ChromeDriverService.java:1)
    at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
    at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)
    at SeleniumFirefox.main(SeleniumFirefox.java:11)
Below is the code used SeleniumFirefox.java:
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.chrome.ChromeDriver;
 org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebElement;
 public class SeleniumFirefox {
   public static void main(String[] args) {
    // TODO Auto-generated method stub
    System.setProperty("webdriver.chromedriver.driver",
           "C://Users//balwinder//Desktop//chromedriver.exe");
    WebDriver driver = new ChromeDriver();
/*try {
    Thread.sleep(5000);
} catch(InterruptedException ex) {
    System.out.println(ex.getMessage());
}*/
   }}
                set webdriver.chrome.driver instead of webdriver.chromedriver.driver
 System.setProperty("webdriver.chromedriver.driver",
           "C://Users//balwinder//Desktop//chromedriver.exe");
Should be:
System.setProperty("webdriver.chrome.driver",
           "C:\\Users\\balwinder\\Desktop\\chromedriver.exe");
OR
System.setProperty("webdriver.chrome.driver",
           "C:/Users/balwinder/Desktop/chromedriver.exe");
NOTE: it will work only if you are first setting the system property and then instantiating chrome driver..
The PATH to the chromedriver.exe file was not set properly. Download the chrome driver zip file and extract it to a folder, go to the extracted folder, copy the path of that folder by clicking on the PATH tab, and explicitly the write .exe file name (.exe is mandatory to write).
Note: Separator between folders should be \ (backslash)
For example please see below:
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Softwares\\Selenium\\chromedriver_win32\\chromedriver.exe");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With