<- Installation of the JWIG System | Contents | Constructing XHTML Documents -> |
The jwig tool makes it easy to compile and install JWIG services. As an example, copy the Hello.jwig service shown below to a directory named test and follow the steps described below. This tool can also be used to update an installed service and to analyze a service to check for errors related to construction of XHTML and receiving of form input. See also the manual page (man jwig) for more documentation.
The Hello.jwig example program:
package test; import dk.brics.jwig.runtime.*; public class Hello extends Service { public class Test extends Session { public void main() { exit [[ <html><head><title>JWIG</title></head><body> <h1>Hello World!</h1> </body></html> ]]; } } } |
To compile a JWIG program, run
jwig compile files
where files is the list of .jwig and .java files constituting the program source. This will translate the JWIG files into Java code and then compile all the Java code to class files. The command must be executed from the root of the directory structure containing the source files, and the source files must appear in subdirectories matching the package names. The CLASSPATH environment variable can be used to specify the classpath.
For the Hello.jwig example, run
jwig compile test/Hello.jwig
This will generate the files test/Hello.class and test/Hello$Test.class.
To install a compiled service, run
jwig install dir files
where dir is a subdirectory of ~/jwig-bin and files is the list of class files and extra files used by the service. For each file in the list, the relative path is preserved in the installation. The path to each class file in the list must match the package name of the class. All jar files placed in the install directory are automatically included in the classpath when the service is started.
(The directory ~/jwig-bin is determined by the configuration of the Apache module. It can be changed in /etc/httpd/conf/bigwig.conf, assuming a typical JWIG install configuation.)
For the Hello.jwig example, run
jwig install ~/jwig-bin/demo test/Hello.class test/Hello$Test.class
This will install the service in the service directory ~/jwig-bin/demo. The class files are placed in ~/jwig-bin/demo/test to match the package name.
To run an installed service from a browser, open the following URL:
http://host/jwig-user/subdir/class
where host is your server host name, user is your user name, subdir is the directory where the service is installed relative to ~/jwig-bin, and class is the name of a class defining a service thread. The class name must be fully qualified with package name.
For the Hello.jwig example, view
http://host/jwig-user/demo/test.Hello*Test
Note that "." is used in the package name of the class, and that "*" is used instead of $ (because $ should not appear unescaped in URLs).
(The mapping from URLs to files on the file system is determined by the configuration of the Apache module mentioned above. Normally, the URL part /jwig-user/* is mapped to ~user/jwig-bin/* on the file system. More details of what is happening when services are running are described in the runtime system section.)
To uninstall a service, run
jwig uninstall dir
where dir is the directory containing the installed service.
For the Hello.jwig example, run
jwig uninstall ~/jwig-bin/demo
This will uninstall the service and remove ~/jwig-bin/demo entirely.
<- Installation of the JWIG System | Contents | Constructing XHTML Documents -> |