title: Getting java.lang.NoClassDefFoundError while using Google Gson library
body: <p>I am using <code>Gson library</code> to convert objects to <code>Json</code> and vice versa. I have copied the <code>jars</code> of that library into a new folder <code>lib</code> and added it to the build path for the project in my <code>Eclipse IDE</code>. </p>
  
  <p>I have one main class where I convert an object into Json using <code>toJson()</code> shown below and send it to a <code>servlet</code> using <code>Apache HttpClient's HttpPost()</code>. </p>
  
  <pre><code>Gson gson= new Gson();
  String json = gson.toJson(names);
  </code></pre>
  
  <p>But in the <code>servlet</code> I am not able to convert the <code>Json</code> into <code>Object</code> using <code>fromJson()</code> when I execute the following code.</p>
  
  <pre><code>Gson gson = new Gson();
  Names names = gson.fromJson(s, Names.class);
  </code></pre>
  
  <p>It is throwing the following exception:</p>
  
  <pre><code>java.lang.NoClassDefFoundError: com/google/gson/Gson
  </code></pre>
  
  <p>Any idea why that could be happening? Should I have copied the <code>jars</code> into the <code>WebContent/WEB-INF/lib</code> folder instead of a new folder called <code>lib</code>?</p>