title: How to execute Cucumber Hooks In java placed in different class other than step definition
body: <h2>Feature file</h2>
  
  <p>Feature: Demo</p>
  
  <p>Scenario: My First Scenario</p>
  
  <p>When enter text in google</p>
  
  <p>And click on Search</p>
  
  <hr>
  
  <p><strong>Step Definition</strong>
  public class LoginSteps {</p>
  
  <pre><code>public WebDriver driver = null;
  
  public LoginSteps() {
      driver = hooks .driver;
  }
  
  @When("^enter text in google$")
  public void enter_text_in_google() throws Throwable {
  
      System.out.println("Inside LoginSteps1");
  
  }
  
  
  @When("^click on search bar$")
  public void click_on_search_bar() throws Throwable {
      System.out.println("Inside LoginSteps2");
  
  }
  </code></pre>
  
  <h2>}</h2>
  
  <p>public class hooks {</p>
  
  <pre><code>public static WebDriver driver = null;
  
  @Before()
  public void inti() {
      System.out
              .println("------------------First Line of the code ---------------");
  }
  
  @After()
  public void tearDown() {
      System.out.println("---------Closing the Sceanrio");
  }
  </code></pre>
  
  <p>}</p>