0

I am compiling my code through Windows 7 using command prompt -- here are details :

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

Gyanendra Dwivedi
  • 5,511
  • 2
  • 27
  • 53
user2779202
  • 11
  • 1
  • 2
  • 8

1 Answers1

1

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. For example, the class path entry foo/ specifies all JAR files in the directory named foo. A classpath entry consisting simply of * expands to a list of all the jar files in the current directory.

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. The order chosen determines whether the classes and resources in foo are loaded before JAR files in foo, or vice versa.

Subdirectories are not searched recursively. For example, foo/* looks for JAR files only in foo, not in foo/bar, foo/baz, etc.

Must read full detail here, it is awesome http://docs.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html

Gyanendra Dwivedi
  • 5,511
  • 2
  • 27
  • 53