title: java.lang.ClassNotFoundException: net.sf.json.JSONObject
body: <p>Am trying to initialize JSONObject in my servlet</p>
  
  <pre><code>        JSONObject obj = new JSONObject();
      UserInfoBean ui= getInfo(empId);
  
      try{
          obj.put("ID", empId);
          obj.put("Name", empName);
          obj.put("Address", address);
          obj.put("Phone", phone);
  
      }
      catch(Exception e){
          e.printStackTrace();
      }
  }**
  </code></pre>
  
  <p>I have added json-lib-2.4-jdk15.jar in my project. Right Click on the project -> BuildPath -> Configure Build Path -> Libraries -> Add External Jar .Then added that particular jar.</p>
  
  <p>But still I get this error:</p>
  
  <blockquote>
    <p>SEVERE: Servlet.service() for servlet
    [com.thirdAttempt.UserInformation] in context with path [/ThirdTry]
    threw exception [Servlet execution threw an exception] with root cause
    java.lang.ClassNotFoundException: net.sf.json.JSONObject  at
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
      at
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
      at com.thirdAttempt.UserInformation.doPost(UserInformation.java:48)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)     at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)  at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
      at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
      at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
      at
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
      at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      at
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
      at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
      at
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
      at
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
      at
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
      at
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)</p>
  </blockquote>