title: Trying to build from the command line, and produce a WAR file
body: <p>My folder layout is:</p>
  
  <pre>
  /web-inf/web.xml
  /web-inf/classes/
  </pre>
  
  <p>HelloWorld.java:</p>
  
  <pre><code>import java.io.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  public class HelloWorld extends HttpServlet{ 
    public void doGet(HttpServletRequest request, 
    HttpServletResponse response)
    throws ServletException,IOException{
    response.setContentType("text/html");
    PrintWriter pw = response.getWriter();
    pw.println("&lt;html&gt;");
    pw.println("&lt;head&gt;&lt;title&gt;Hello World&lt;/title&gt;&lt;/title&gt;");
    pw.println("&lt;body&gt;");
    pw.println("&lt;h1&gt;Hello World&lt;/h1&gt;");
    pw.println("&lt;/body&gt;&lt;/html&gt;");
    }
  }
  </code></pre>
  
  <p>I want to do the following:</p>
  
  <ol>
  <li>build everything via the command line</li>
  <li>publish to Tomcat's webapps directory using a .war file</li>
  </ol>
  
  <p>Where should I put my <code>HelloWorld.java</code> file, and how to compile it using the command line?
  I believe the output of the <code>HelloWorld.java</code> goes in the <code>/classes/</code> folder.</p>
  
  <p>Then how do I generate the <code>.war</code> file?</p>
  
  <p>I tried just manually compiling like this:</p>
  
  <pre>javac HelloWorld.java</pre>
  
  <p>And I got errors relating to the imports i.e. it couldn't find the libraries in my path. Is there a Java EE library I have to download and add it to my path?</p>