Wolfram ResearchProductsPurchasingServices & ResourcesAbout UsOur Sites
Services & Resources / Archive
-----
 /
webMathematica
*Mathematica
*Network Mathematica
*webMathematica
*gridMathematica
*Personal Grid Edition
*Wolfram Workbench
*Wolfram Education Group
*Application Packages
*Mathematica for Students
*Mathematica CalcCenter
*Publicon
*A New Kind of Science Explorer
*Mathematical Explorer
*Mathematica Teacher's Edition
*Calculus WIZ
*Mathematica Player
*Ask about this page
*Print this page
*Email this page
*Give us feedback
*
Sign up for our newsletter:

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:

 

http://www.uk.research.att.com/vnc/download.html

 

For Solaris, go to http://www.uk.research.att.com/vnc/dist/vnc-3.3.3r2_sun4_sosV_5.5.tar.Z.

 

For Linux, go to http://www.uk.research.att.com/vnc/dist/vnc-3.3.3r2_x86_linux_2.0.tgz.

 

If you need the VNC documentation, you can obtain it from the following URL.

 

http://www.uk.research.att.com/vnc/dist/vnc-3.3.3r1_x86_linux_2.0.tar.Z

 

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: vncviewer, vncserver, vncpasswd, vncconnect, and Xvnc as well as a subdirectory, classes, which are the Java Class files.

 

There is also a README file with instructions on how one can install the Xvnc files.

2.

Install Xvnc.

 

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 /usr/local/bin:

 

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 /usr/local/vnc/classes:

 

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 .Mathematica directory in the default location. The same holds true for xauth with the .Xauthority 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 /usr/bin, you will have to edit the #!/usr/bin/perl first line of the vncserver 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 ~/.vnc 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 ~/.vnc/xstartup 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 twmrc (/etc/X11/twm/system.twmrc on RedHat 7.1) to ~/.twmrc.

b.

Edit ~/.twmrc 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.

 

Start up VNC again:

 

vncserver :1 -geometry 800x600 -depth 24

 

Start tomcat.

 

Use your browser to access a webMathematica example that uses the Mathematica frontend, such as Plot.msp.

 

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 /tmp/webMathematica for storing preferences and to use display 1.

 

This parameter can appear in MSP.conf 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.

 

Startup:

 

su tomcat -c 'vncserver :1 -geometry 800x600 -depth 24'

 

Shutdown:

 

su tomcat -c 'vncserver -kill :1'

 

For more information on VNC, please refer to the VNC documentation at http://www.uk.research.att.com/vnc/.

Download this FAQ as a Mathematica 5.2 Notebook






 © 2008 Wolfram Research, Inc.  Terms of Use  Privacy Policy