編譯的servlet我想編譯NetBeans外部的servlet。我做了一個簡單的Hello World servlet,它產生了這些編譯錯誤。用javac
import javax.servlet.ServletException;
^
ServletTester.java:4: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
ServletTester.java:6: cannot find symbol
symbol: class HttpServlet
public class ServletTester extends HttpServlet {
^
ServletTester.java:7: cannot find symbol
symbol : class HttpServletRequest
location: class ServletTester
protected void processRequest(HttpServletRequest request, HttpServletResponse response) t
^
ServletTester.java:7: cannot find symbol
symbol : class HttpServletResponse
location: class ServletTester
protected void processRequest(HttpServletRequest request, HttpServletResponse response) t
^
ServletTester.java:7: cannot find symbol
symbol : class ServletException
location: class ServletTester
protected void processRequest(HttpServletRequest request, HttpServletResponse response) t
6 errors
顯然,javax.servlet
包不能被定位。我從GlassFish的安裝javax.servlet.jar
,但如果我不javac ServletTester.java -classpath /opt/glassfish3/glassfish/modules/
我仍然得到同樣的錯誤。
什麼是手工編譯的Servlet的正確方法?
你應該能夠使用通配符:[作爲一個特別的方便,包含*的基本名稱的類路徑元素被認爲等效於指定擴展名爲.jar或.JAR的目錄中的所有文件的列表。] (http://download.oracle.com/javase/6/docs/technotes/tools/solaris/javac.html#options) – McDowell 2011-04-26 14:04:53