The following program has been created as HelloWorld.java:
/* HelloWorld.java */
A script file is needed to run the java application, this is called HelloWorld.cgi:
#!/bin/sh /usr/bin/java HelloWorld
There are a few points to note. The student webserver is set up so that any file ending in .cgi is taken to be a cgi script. Normally these scripts are stored in a special directory. cgi scripts are run by the user nobody. You have to tell nobody which shell to run and give the full path, hence /usr/bin/java. If your code uses any additional libraries, the -classpath option of the java command must be used. You have to get the access permissions right as well!
Now click on here to run the program.
For the C programmers amongst you, here is the same again, but written in C:
/* HelloWorld.c */
Now click on here to run this program.
If programming is too much effort, the same can be achieved with a Shell script:
echo Content-type: text/html
Click on here to run this program.
You can decide which you think is the faster to run/write!
If you are a student, the system setup has now changed so that student accounts can no longer run cgi scripts, so the above is for information only.
This document was last modified on: 24th March 2014