How to launch chrome browser using selenium webdriver ?

package SeleniumLearn.com;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
import com.thoughtworks.selenium.Selenium;

public class MyData {
    public WebDriver driver;
    public Selenium selenium;
    
    @Test
        public void LaunchChromeBrowser() 
        {
        driver.get("http://www.seleniumlearn.com");
        }
    
    @BeforeTest
        public void beforeTest() 
        {
         //---> for Windows machine
        System.setProperty("webdriver.chrome.driver", "E:\\Library\\chromedriver.exe");  // Your chromedriver path.
        driver=new ChromeDriver();
         
        //---> for Linux machine
        System.setProperty("webdriver.chrome.driver",  "/home/chinna/lib/chromedriver");   // Your chromedriver path.
        driver = new ChromeDriver();
        driver.manage().window().maximize();
        }
    @AfterTest
        public void afterTest() {
    }
}

Tags: