How to use Xvnc with webMathematica
 Xvnc, the Unix VNC server, presents an attractive alternative to Xvfb and can be used in its place when configuring the X Window System to work with webMathematica. Xvnc's main advantages are its simple installation, the fact that it allows you to interact with the X client, and that it is also accessible via a Java-enabled web browser. In order to install Xvnc and use it in conjuction with webMathematica, it is necessary to follow these instructions: | 1. | Obtain the appropriate Xvnc distribution from the following location: |
| | If you need the VNC documentation, you can obtain it from the following URL. |
| | The Xvnc archive for Solaris can be uncompressed using the following command syntax: |
| | zcat vnc-3.3.3r2_sun4_sosV_5.5.tar.Z | tar -xvf - |
| | The Xvnc archive for Linux can be uncompressed using the following command syntax: |
| | tar xvzf vnc-3.3.3r2_x86_linux_2.0.tgz |
| | The extracted directory layout contains five files: , , , , and as well as a subdirectory, , which are the Java Class files. |
| | There is also a file with instructions on how one can install the Xvnc files. |
| | The first step should be to copy these programs to some directory which is included in your PATH environment variable. One example of that is : |
| | cp vncviewer vncserver vncpasswd vncconnect Xvnc /usr/local/bin |
| | If you want to use the Java VNC viewer, you should copy the class files from the classes directory to some suitable installation directory such as : |
| | mkdir - p /usr/local/vnc/classes |
| | cp classes/* /usr/local/vnc/classes |
| | Xvnc by default needs to write files to the home directory of the user running it. As such, it would be a good idea to create a home directory for the user that will be running Tomcat. This also lets Mathematica create the directory in the default location. The same holds true for with the file. |
| | Use su to become the tomcat user, as in su - tomcat. |
| | Before running VNC, you need to check that location of Perl on your system. If Perl is not installed in , you will have to edit the #!/usr/bin/perl first line of the script. |
| | You may also have to change Xvnc's font path and color database. If the installation of X is not in the standard place it may be a good idea to add arguments to the Xvnc command line to set these. These should be appended to the $cmd variable at the comment # Add font path and color database.... |
| | Run vncserver. The first time it is run, vncserver will create directory (along with some default configuration files) and call vncpasswd to set a password for vncserver sessions. The output will look something like this: |
| | You will require a password to access your desktops.
Password:
Verify:
New 'X' desktop is test.wolfram.com:1
Creating default startup script /home/tomcat/.vnc/xstartup
Starting applications specified in /home/tomcat/.vnc/xstartup
Log file is /home/tomcat/.vnc/mymachine.mydomain.com:1.log |
| | At this point you can connect to the X desktop using a standalone VNC client (to mymachine.mydomain.com:1 in the example above), or using a Java-capable web browser (http://mymachine.mydomain.com:5801). |
| | Run vncserver -kill :1 to kill the VNC session. |
| | It would be a good idea to take a look at the script. The default is: |
| | #!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm & |
| | You can comment out or delete the xterm line. If you do not wish to have a window manager running, you can also comment out twm. |
| | Having a window manager can be useful, so if you choose to run twm, you need to take the following steps: |
| a. | Make a copy of the system default ( on RedHat 7.1) to . |
| b. | Edit and add the string RandomPlacement on a line by itself at the end of the file. |
| | Without the RandomPlacement directive, twm will wait for you to manually place the window which may be inconvenient. |
| | Of course, it is possible to use a different window manager, such as sawfish, if it is available on your system. |
| | vncserver :1 -geometry 800x600 -depth 24 |
| | Use your browser to access a webMathematica example that uses the Mathematica frontend, such as . |
| | Note that you will have to configure webMathematica to use display :1, using the configuration parameter FrontEndLaunchCommand. As described in the webMathematica documentation, your site may wish to call on the services of the Mathematica front end in order to make images or to use notebook API functions. If this is the case, you may need to set special configuration parameters by setting FrontEndLaunchCommand. Alternatively, you may wish to use a different command for launching the front end. |
| | For example, if you wish to tell the front end to connect to a different X server for display, you could do something like the following. |
| | FrontEndLaunchCommand=mathematica -mathlink -display :1 |
| | In addition, you may wish to set the directory the front end uses for preferences with the front end command line option -preferencesDirectory. |
| | FrontEndLaunchCommand=mathematica -mathlink -display :1 -preferencesDirectory /tmp/webMathematica |
| | This instructs the front end to use the directory for storing preferences and to use display 1. |
| | This parameter can appear in and in a pool-specific configuration file. |
| | Now, you can connect to the VNC server, and you will be ablesee the Mathematica frontend window. |
| | Note that you can always add VNC to your Tomcat startup/shutdown scripts. |
| | su tomcat -c 'vncserver :1 -geometry 800x600 -depth 24' |
| | su tomcat -c 'vncserver -kill :1' |
Download this FAQ as a Mathematica 5.2 Notebook
Questions or comments? Send email to support@wolfram.com.
| |