wood burning stoves 2.0*
The moose likes Servlets and the fly likes compiling simple servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "compiling simple servlet" Watch "compiling simple servlet" New topic
Author

compiling simple servlet

harshal deolekar
Greenhorn

Joined: Mar 01, 2012
Posts: 22
i am using apache tomcat server.
i wrote simple "FirstServlet.java" and stored in my directory : "C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\servlet\WEB-INF\classes>"
i also created web.xml file and saved it outside classes folder, which includes following code:
<web-app>
<servlet>
<servlet-name>FirstServlet</servlet-name>
<servlet-class>/FirstServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FirstServlet</servlet-name>
<url-pattern>/FirstServlet</url-pattern>
</servlet-mapping>
</web-app>



in cmd prompt.. i setted c:\set classpath="C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar"
after that, i started tomcat and my project "servlet" in which my "FirstServlet.java" got successfull deployed... "true"

but i am not able to compile it ... "javac FirstServlet.java"
i am getting error 'javac' is not recognized as internal or external command,operable program or batch file.....
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 513

harshal deolekar wrote:
i am getting error 'javac' is not recognized as internal or external command,operable program or batch file.....

Did you set JAVA_HOME and PATH?


Regards, Prasad
SCJP 5 (93%)
harshal deolekar
Greenhorn

Joined: Mar 01, 2012
Posts: 22
i have setted classpath in command prompt to c:\set classpath="C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar"

i havent set JAVA_HOME... can you be precise ?..
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19682
    
  20

Whenever you install the JDK on your machine, it's a very good advice to setup environment variable JAVA_HOME to point to the directory where you've installed the JDK. For instance, C:\jdk1.7.0_03. The steps for doing so are similar to those described in http://www.coderanch.com/how-to/java/HowToSetTheClasspath.

After that you should add the JDK's bin folder to your PATH variable. I say "add to" - don't replace your current value or your system may stop working properly. Anyway, just add ;%JAVA_HOME%\bin at the end of the current value. The %JAVA_HOME% part will be replaced by the actual value, even if you change that.


Another remark: your servlet class value is invalid. It needs to be the class name, and can therefore never start with a /. You should also put your servlets inside packages, and then include the package name in the servlet class value.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compiling simple servlet