简体   繁体   English

在Windows 7中使用命令提示符设置类路径

[英]Setting Classpath using command prompt in Windows 7

I am compiling my code through Windows 7 using command prompt -- here are details : 我正在使用命令提示符通过Windows 7编译代码-以下是详细信息:

I set the class path like this : 我像这样设置类路径:

set classpath= %classpath%;C:\java-programes\Servlet-Programing-new1\TotalUsersOnline\lib\servlet-api\*.jar;C:\java-programes\Servlet-Programing-new1\TotalUsersOnline\lib\servlet\*.jar;

and then I tried to compile my file like : 然后我尝试像这样编译我的文件:

javac -d ..\classe com\java\controller\LoginServlet.java

output: 输出:

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

after that I tried like : 之后,我尝试像:

javac  -classpath C:\java-programes\Servlet-Programing-new1\TotalUsersOnline\lib\servlet-api\*.jar com\java\controller\LoginServlet.java

then the output I got is : 那么我得到的输出是:

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

Please Help on this As I am stuck on this point and I am not getting anything..how to go forward.I need help badly :( 请对此提供帮助因为我坚持这一点,但是我什么也没得到。.如何前进。我急需帮助:(

Thanks in Advance 提前致谢

Understanding class path wildcards 了解类路径通配符

Class path entries can contain the basename wildcard character , which is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR. 类路径条目可以包含基本名称通配符,该通配符被认为等同于指定扩展名为.jar或.JAR的目录中所有文件的列表。 For example, the class path entry foo/ specifies all JAR files in the directory named foo. 例如,类路径条目foo /指定目录foo中的所有JAR文件。 A classpath entry consisting simply of * expands to a list of all the jar files in the current directory. 仅由*组成的类路径条目将扩展为当前目录中所有jar文件的列表。

A class path entry that contains * will not match class files. 包含*的类路径条目将与类文件不匹配。 To match both classes and JAR files in a single directory foo, use either foo;foo/* or foo/*;foo. 要在单个目录foo中匹配类和JAR文件,请使用foo; foo / *或foo / *; foo。 The order chosen determines whether the classes and resources in foo are loaded before JAR files in foo, or vice versa. 选择的顺序确定是否在foo中的JAR文件之前加载foo中的类和资源,反之亦然。

Subdirectories are not searched recursively. 子目录不是递归搜索的。 For example, foo/* looks for JAR files only in foo, not in foo/bar, foo/baz, etc. 例如,foo / *仅在foo中查找JAR文件,而不在foo / bar,foo / baz等中查找。

Must read full detail here, it is awesome http://docs.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html 必须在这里阅读完整的详细信息,这太棒了http://docs.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM