title: Cucumber: Class not found com.example.runner.RunnerTest
body: <p>I have a <code>maven</code> project to run <code>cucumber</code> and <code>selenium</code>.  The <code>*.feature</code> files are defined in the <code>src/features</code>, and the steps are defined in the <code>src/test/java/com/example/steps</code>.</p>
  
  <p><a href="https://i.stack.imgur.com/yRVBJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yRVBJ.png" alt="enter image description here"></a></p>
  
  <p>I have also defined a test runner class as below:</p>
  
  <pre><code>package com.example.runner;
  
  import org.junit.runner.RunWith;
  import cucumber.api.CucumberOptions;
  import cucumber.api.junit.Cucumber;
  
  @RunWith(Cucumber.class)
  @CucumberOptions(
               features={"src/features"},
               glue="com/example/steps")
  public class RunnerTest {
  
  }
  </code></pre>
  
  <p>The problem is: <strong>When i run the class it complains with:</strong></p>
  
  <pre><code>Class not found com.example.runner.RunnerTest
  java.lang.ClassNotFoundException: com.example.runner.RunnerTest
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:688)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:421)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
  </code></pre>
  
  <p>The question is, <strong>why it does not recognized the runner calss?</strong></p>
  
  <hr>
  
  <p><strong>Update:</strong></p>
  
  <p>when i run the feature file by </p>
  
  <p><strong>open feature file -> right click -> Run as -> 1 cucumber feature</strong> </p>
  
  <p><em>It works well</em></p>
  
  <p>I changed the <code>glue="com/example/steps"</code> to <code>glue="com.example.steps"</code> and it complains with :</p>
  
  <pre><code>java.lang.NullPointerException
      at com.example.steps.Click_Steps.i_am_in(Click_Steps.java:23)
      at ✽.Given I am in "http://suvian.in/selenium/1.6checkbox.html"(CheckBox.feature:14)
  </code></pre>
  
  <p>and when i refer to the file:</p>
  
  <pre><code>base.getDriver().navigate().to(uri);
  </code></pre>
  
  <p>But as i said, this line work pretty well when i run the feature file using <code>Run as -&gt; Cucumber</code></p>