I could not compile my servlets. It says package javax.servlet.* dosenot exist.
It means that the classpath for javac
is not been correctly specified. It should go like so:
javac -cp .;"/path with spaces/to/servlet-api.jar" com/example/YourServlet.class
Note that you need to surround a path with spaces by doublequotes.
I could not connect with local host in chrome nor in explorer. These errors are appearing inspite of server instance running.
Then you used the wrong domain/port. When running Tomcat at the local machine, the domain should at least be localhost
. The actual port can be determined in Tomcat/conf/server.xml
file. It defaults to 8080
, but can be changed during the Windows setup wizard. The final URL should look like http://localhost:8080. If you use port 80
which is the default HTTP port, then the :80
part can be omitted from the URL.
Classpath to java sdk and tomcat are different.
The %CLASSPATH%
environment variable is worthless. Use -cp
argument. If you want to avoid long typing/remembering everytime, consider using a .bat
file with the command, or a build tool like Ant, or an IDE like Eclipse.
The %JAVA_HOME%
environment variable is however important. Tomcat needs to know it in order to have access to the toolset to compile JSP files. The %JAVA_HOME%
should point to the installation directory of the JDK.