Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compiling simple servlet

 
harshal deolekar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 667
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
harshal deolekar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20529
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic