Linuxdoc Linux Questions
Click here to ask our community of linux experts!
Custom Search
Next Previous Contents

2. Setting Up Your Server to Run Java CGI Programs (With Explanations)

This section will lead you through installing my Java CGI package with copious explanations so that you know what the effects of your actions will be. If you just want to install the programs and don't care about the whys & wherefores, skip to Setting Up Your Server to Run Java CGI Programs (The Short Form).

2.1 System Requirements

This software should work on any unix-like web server that has the Java Development Kit installed. I am using it on a Debian Linux system running apache as the HTTP daemon. If you find that it does not run on your server, please contact the mailing list. See The Mailing List for details.

Unfortunatly, the Java run-time interpreter seems to be something of a memory hog -- you may want to throw another few megabytes of RAM onto your server if you will be using Java CGI programs a lot.

2.2 Java CGI Add-On Software

The software that I wrote to aid in this is called Java CGI. You can get it from ftp://ftp.orbits.com/pub/software/java_cgi-0.5.tgz. (The version number may have changed.)

2.3 Unpacking the Source

Find a convenient directory to unpack this package into. (If you don't already have a standard place to put packages, I suggest that you use /usr/local/src.) Unpack the distribution with this command:

gzip -dc java_cgi-0.5.tgz | tar -xvf -
This will create a directory called java_cgi-0.5. In there you will find the files referenced in the rest of this document. (If the version number has changed, use the instructions from within that distribution from this point on.)

2.4 Decide On Your Local Path Policies

You need to decide where you want your Java CGI programs to live. Generally, you will want to put them in a directory in parallel with your cgi-bin directory. My apache server came configured to use /var/www/cgi-bin as the cgi-bin directory, so I use /var/www/javacgi as the directory to put Java CGI programs in. You probably do not want to put your Java CGI programs into one of the existing CLASSPATH directories. Edit the Makefile to reflect your system configuration. Make sure that you are logged in as the root user and run make install. This will compile the Java programs, modify the java.cgi script to fit in with your system and install the programs in the appropriate places. If you want the HTML version of this documentation and an HTML test document in addition, run make all instead.

2.5 Testing your installation.

Installed from the distribution are HTML documents called javacgitest.html, javaemailtest.html and javahtmltest.html. If you installed all in the previous section, it will be in the directory you specified for WEBDIR in the Makefile. If you didn't, you can run make test to build them from javacgitest.html-dist, javaemailtest.html-dist and javahtmltest.html-dist.

When you are sure that your installation is working correctly, you may wish to remove CGI_Test.class, Email_Test.class and HTML_Test.class from your JAVACGI directory and javacgitest.html, javaemailtest.html and javahtmltest.html from your WEBDIR directory as they show the user information that is normally only available to the server.


Next Previous Contents