java - jetty package org.json.simple does not exist -
i have simple servlet used jetty.
this fragment of servlet:
import org.json.simple.jsonobject; import org.json.simple.jsonvalue; public class oscar4servlet extends httpservlet { ... protected void dopost(httpservletrequest req, httpservletresponse resp) throws servletexception, ioexception { request.setcharacterencoding("utf8"); response.setcharacterencoding("utf8"); response.setcontenttype("application/json"); printwriter out = resp.getwriter(); jsonobject obj = new jsonobject(); obj.put("message", "hello server"); out.print(obj); } }
after invoking:
javac -cp /usr/share/jetty/lib/servlet-api-2.5.jar oscar4servlet.java
i'm getting error:
oscar4servlet.java:5: error: package org.json.simple not exist import org.json.simple.jsonobject; ^ oscar4servlet.java:6: error: package org.json.simple not exist import org.json.simple.jsonvalue;
although have json-simple-1.1.1.jar
(downloaded http://code.google.com/p/json-simple/downloads/detail?name=json-simple-1.1.1.jar) in web_inf/lib
directory... ideas why?
when compiling need specify full compilation classpath. need modify command to:
javac -cp /usr/share/jetty/lib/servlet-api-2.5.jar:<path-to>/json-simple-1.1.1.jar oscar4servlet.java
(and of course other dependencies)
alternatively, if dependencies in /some-path/web-inf/lib
can do:
javac -cp /usr/share/jetty/lib/servlet-api-2.5.jar:/some-path/web-inf/lib/* oscar4servlet.java
Comments
Post a Comment