title: How to use an Ant script to start and stop Tomcat server?
body: <p>I need to start and stop Tomcat server using Ant script, however I found a script on Stack Overflow but when I am using it, it is giving below mentioned error.</p>
  
  <p>The script and the message on console I am getting is mentioned below :</p>
  
  <pre><code>&lt;project name="sample"&gt;
  &lt;property name="name" value="sample"/&gt;
  &lt;path id="catalina-ant-classpath"&gt; 
  &lt;fileset dir="C:\Users\vivsharm\Downloads\apache-tomcat-7.0.64-windows-x64\apache-tomcat-7.0.64\lib"&gt; 
  &lt;include name="catalina-ant.jar"/&gt; 
  &lt;/fileset&gt; 
  &lt;/path&gt; 
  &lt;taskdef name="start" classname="org.apache.catalina.ant.StartTask"&gt; 
  &lt;classpath refid="catalina-ant-classpath"/&gt; 
  &lt;/taskdef&gt;
  
  &lt;taskdef name="stop" classname="org.apache.catalina.ant.StopTask"&gt;
  &lt;classpath refid="catalina-ant-classpath"/&gt;
  &lt;/taskdef&gt;
  
  &lt;target name="start" description="Start Tomcat application"&gt;
  &lt;start url="http://localhost:8080/"
  username="uname"
  password="pwd"/&gt;
  &lt;/target&gt;
  &lt;target name="stop" description="Stop Tomcat application"&gt;
  &lt;stop url="http://localhost:8080/"
  username="uname"
  password="pwd"/&gt;
  &lt;/target&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>and the error message I am getting is below :</p>
  
  <pre><code>C:\StartAndStopTomcat&gt;ant start
  Buildfile: C:\StartAndStopTomcat\build.xml
  
  start:
  
  BUILD FAILED
  C:\StartAndStopTomcat\build.xml:19: Must specify 'path' attribute
  
  Total time: 0 seconds
  
  C:\StartAndStopTomcat&gt;ant stop
  Buildfile: C:\StartAndStopTomcat\build.xml
  
  stop:
  
  BUILD FAILED
  C:\StartAndStopTomcat\build.xml:24: Must specify 'path' attribute
  
  Total time: 0 seconds
  
      enter code here
  
  C:\StartAndStopTomcat&gt;
  </code></pre>