This is an old revision of the document!


Running Apache Tomcat

These instructions assume that you have a functioning installation of the JDK (I'm using 1.6.0_21), and that the java and javac commands are in your path. I've tested briefly on both Windows and Red Hat Enterprise Linux, and the instructions work for me. This is a wiki, so if you have better instructions, feel free to edit.

  1. Go to http://tomcat.apache.org/ and find the download page for the latest version. As of this writing, that's version 7, available from http://tomcat.apache.org/download-70.cgi
  2. Extract the contents of the zip file and move them somewhere appropriate, such as c:\Program Files\Tomcat\ or ~/tomcat/.
  3. Edit the file conf/context.xml and change the line which reads:
    <Context>
    so that it reads:
    <Context reloadable="true">
  4. If you're going to be running JESS code, copy the jess.jar file from the lib folder of your JESS installation into the lib folder of your Tomcat installation.
  5. Run the startup script. On Windows, this is bin\startup.bat; on Linux and OS X, this is bin/startup.sh.
  6. Launch a web browser and point it to http://localhost:8080/
  7. Make sure your browser displays the default Tomcat home page.

Adding your project to Tomcat

  1. Create a new folder for your project under the webapps folder of your Tomcat installation.
  2. Inside that folder, create a new folder named WEB-INF.
  3. Inside the WEB-INF folder, create a folder named classes.
  4. Copy the .class files from your project into the classes folder, or copy the .java source files and follow the instructions below to compile them.
  5. Create a file named web.xml inside the WEB-INF folder. Here's a sample:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    
    <!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd">
    
    <web-app>
        <servlet>
            <servlet-name>HelloJess</servlet-name>
            <servlet-class>HelloJess</servlet-class>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>
                HelloJess
            </servlet-name>
            <url-pattern>
                /index.html
            </url-pattern>
        </servlet-mapping>
    </web-app>
  6. That web.xml file will work for a program which implements a class named HelloJess, as defined in the source like this:
    public class HelloJess extends HttpServlet {
    You will want to alter your web.xml file accordingly.
  7. Visit http://localhost:8080/yourproect/, where yourproject is the name of the folder you created under webapps. If everything worked, the output of your program will be here.

Compiling your code

You'll need to make sure that the servlet API and JESS classes are in your classpath when compiling. This command works for me, when my shell is in the classes folder under WEB-INF in the project folder under webapps:

javac -classpath ..\..\..\..\lib\jess.jar;..\..\..\..\lib\servlet-api.jar *.java
That's for Windows. For everything else, it would be:
javac -classpath ../../../../lib/jess.jar;../../../../lib/servlet-api.jar *.java

Navigation

The best way to find something here is to use the search box in the upper right or the site index link below.

Print/export
Mobile QR Link