java.lang.NullPointerException at feature.StepDefinitions cucumber
<p>I'm getting a <code>NullPointerException</code> as follows:</p>

<p>Feature: Login action</p>

<p>Scenario:</p>

<pre><code>Successful Login with Valid Credentials # C:/Users/chaitanya/workspace/cucumber2/src/feature/myfeature.feature:3
Given User is on Home Page                      # StepDefinitions.User_is_on_Home_Page()
When User enters UserName and Password          # StepDefinitions.User_enters_UserName_and_Password()
  java.lang.NullPointerException
    at feature.StepDefinitions.User_enters_UserName_and_Password(StepDefinitions.java:25)
    at ?.When User enters UserName and Password(C:/Users/chaitanya/workspace/cucumber2/src/feature/myfeature.feature:5)

Then Message displayed Login Successfully       # StepDefinitions.Message_displayed_Login_Successfully()
</code></pre>

<p>Code:</p>

<pre><code>package feature;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;

public class StepDefinitions {
  public static WebDriver driver;

  @Given("^User is on Home Page$")
  public void User_is_on_Home_Page() throws Throwable {
    WebDriver driver = new FirefoxDriver();
    driver.manage().window().maximize();
    driver.get("http://opensource.demo.orangehrmlive.com/");
 }

  @When("^User enters UserName and Password$")
  public void User_enters_UserName_and_Password() throws Throwable {
    driver.findElement(By.name("txtUsername")).sendKeys("admin");
    driver.findElement(By.xpath("//input[@id='txtPassword']")).sendKeys("admin");
    driver.findElement(By.name("Submit")).click();
    Thread.sleep(3000);
  }

  @Then("^Message displayed Login Successfully$")
  public void Message_displayed_Login_Successfully() throws Throwable {
      System.out.println("login completed");
  }
}
</code></pre>