title: java.lang.NoClassDefFoundError: javax/json/Json
body: <p>I have a simple Java project where I would like to build a Json string. For this, I use javax.json:</p>
  
  <pre><code>import javax.json.Json;
  import javax.json.JsonObjectBuilder;
  
  public class MyClass {
      public void MyFunc() {
          JsonObjectBuilder myBuilder = Json.createObjectBuilder(); # this line will trigger the exception
          // And some other code
      }
  }
  </code></pre>
  
  <p>The project is build with maven, and in the pom I have added these dependencies:</p>
  
  <pre><code>&lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;junit&lt;/groupId&gt;
      &lt;artifactId&gt;junit&lt;/artifactId&gt;
      &lt;version&gt;3.8.1&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;javax.json&lt;/groupId&gt;
      &lt;artifactId&gt;javax.json-api&lt;/artifactId&gt;
      &lt;version&gt;1.0&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.glassfish&lt;/groupId&gt;
        &lt;artifactId&gt;javax.json&lt;/artifactId&gt;
        &lt;version&gt;1.0.4&lt;/version&gt;
    &lt;/dependency&gt;    
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>Compilation is ok.
  When I execute the code using that command:</p>
  
  <pre><code>java -cp target/classes MyClass
  </code></pre>
  
  <p>The main is in MyClass. I get:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: javax/json/Json
  [...]
  Caused by: java.lang.ClassNotFoundException: javax.json.Json
          at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
          ... 6 more
  </code></pre>
  
  <p>on the call to Json.createObjectBuilder().</p>
  
  <p>Symptom is the same if you run it in the targer folder like that:</p>
  
  <pre><code>java MyClass
  </code></pre>
  
  <p>I have checked in my ~/.m2/repository folder and i have javax/json/javax.json-api/1.0/javax.json-api-1.0.jar. When I unzip it, I can see the Json.class file.</p>
  
  <p>What's wrong ???</p>