Compiling a Java Servlet Source File

You can develop servlets manually through the command line and a text editor. Parallels Pro Control Panel provides a Java software development kit and a Java run time environment for the Site Administrator when you enable the service Development Tools for the site. The service installs a script java.sh in /etc/profile.d/. When you log onto the server, your shell runs this script and relevant Java-environment variables are set up for you. You can add additional $CLASSPATH, for any site, by editing the script /etc/profile.d/java.sh.

To compile a Java servlet source file into a Java class file for Tomcat

  1. Log on to Parallels Pro Control Panel as the Site Administrator.
  2. Change to the directory in which the source servlet code file is located.
  3. Enter the following command.

    javac <myServlet.java> (substitute your file name for the file myServlet.java).

  4. If the compilation is successful and no errors are reported, the file myServlet.class can be located in the same directory.
  5. To use this servlet, copy the file myServlet.class in the directory WEB-INF/classes.