title: Same instance of Webdriver in multiple classes in Java Selenium
body: <p>Class that contains all classes</p>
  
  <pre><code>public class AllTests{
      public static void main(String[] args) {
          Loginer.login();
          Example.linkOne();
          Examplee.linkTwo();
      }
  }
  </code></pre>
  
  <p>Class that starts the Firefox driver and logins</p>
  
  <pre><code>public class Loginer{
      public static login(){
          WebDriver driver = new FirefoxDriver();
          driver.get("http://LINKISHERE.COM/");
          //other login code
      }
  }
  </code></pre>
  
  <p>Actual Selenium code that clicks links and stuff</p>
  
  <pre><code>public class Example{
  
      public static linkOne() {
              **driver**.findElement(By.className("CLASSNAME")).click();
      }
  
      public static linkTwo() {
              **driver**.findElement(By.className("CLASSNAME")).click();
      }
  }
  </code></pre>
  
  <p>I'm pretty new to JAVA, I only worked with python till now.
  What I'm trying to do is have multiple tests split into multiple classes that are part of the AllTests class, so I can take them out or add new ones with easy. 
  My trouble has been using the same WebDriver in all classes due to this <code>java.lang.NullPointerException</code>. Is this recommended or should it be fine to have Selenium start a new WebDriver every time?</p>