我正在使用命令提示符通过 Windows 7 编译我的代码 - 以下是详细信息:
我这样设置类路径:
set classpath= %classpath%;C:\java-programes\Servlet-Programing-new1\TotalUsersOnline\lib\servlet-api\*.jar;C:\java-programes\Servlet-Programing-new1\TotalUsersOnline\lib\servlet\*.jar;
然后我尝试编译我的文件,如:
javac -d ..\classe com\java\controller\LoginServlet.java
输出:
com\java\controller\LoginServlet.java:7: package javax.servlet does not exist
import javax.servlet.RequestDispatcher;
^
com\java\controller\LoginServlet.java:8: package javax.servlet does not exist
import javax.servlet.ServletException;
^
com\java\controller\LoginServlet.java:9: package javax.servlet.http does not exist
import javax.servlet.http.HttpServlet;
^
com\java\controller\LoginServlet.java:10: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletRequest;
^
com\java\controller\LoginServlet.java:11: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletResponse;
^
com\java\controller\LoginServlet.java:13: cannot find symbol
symbol: class HttpServlet
public class LoginServlet extends HttpServlet{
^
com\java\controller\LoginServlet.java:21: cannot find symbol
symbol : class HttpServletRequest
location: class com.java.controller.LoginServlet
public void service(HttpServletRequest request, HttpServletResponse response)
^
com\java\controller\LoginServlet.java:21: cannot find symbol
symbol : class HttpServletResponse
location: class com.java.controller.LoginServlet
public void service(HttpServletRequest request, HttpServletResponse response)
^
com\java\controller\LoginServlet.java:22: cannot find symbol
symbol : class ServletException
location: class com.java.controller.LoginServlet
throws ServletException, IOException {
^
com\java\controller\LoginServlet.java:46: cannot find symbol
symbol : class RequestDispatcher
location: class com.java.controller.LoginServlet
RequestDispatcher dispatcher = request.getRequestDispatcher("/home.jsp");
^
com\java\controller\LoginServlet.java:20: method does not override or implement a method from a supertype
@Override
之后我尝试过:
javac -classpath C:\java-programes\Servlet-Programing-new1\TotalUsersOnline\lib\servlet-api\*.jar com\java\controller\LoginServlet.java
那么我得到的输出是:
javac: invalid flag: C:\java-programes\Servlet-Programing-new1\TotalUsersOnline\lib\servlet-api\servlet-api-2.5.jar
Usage: javac <options> <source files>
use -help for a list of possible options
请对此提供帮助,因为我被困在这一点上,我没有得到任何东西..如何前进。我非常需要帮助:(
提前致谢