This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript 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: 672
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
Posts: 20822
68
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.
 
You can thank my dental hygienist for my untimely aliveness. So tiny:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!