Getting Started with JavaViewLib v3.22

Note: this page includes ~10 interactive Maple plots with JavaView-Lite
 -downloading of the plots may take some time.

Also note: more getting-started examples are given in the worksheet gettingStarted.mws. A separate gallery produced with geometryPlots.mws shows more than 100 interactive Maple plots and options. Both worksheets are bundled with JavaView in the JVL download package.


The JavaViewLib (JVL) is a Maple Research PowerTool that augments and enhances the visualization of Maple plot objects by making use of a far superior viewing and modelling environment.  It further allows these plots to preserve their dynamic qualities when exported to an HTML page. This worksheet serves as a user guide and test script for JVL. Where issues beyond the control of this package arise they will be mentioned. Note that launching applications from within Maple causes Maple to block execution. If the launched applications exits then Maple continues. The following demonstration was performed on a Windows platform. You can make your own appropriate modifications of the path names for Unix. It is recommended that you make a copy of this worksheet before running through it as to avoid overwriting it. This package makes much reference to two file formats of primary interest to JVL: .mpl and .jvx.- refer to the section 'More on Export*' for details.

Requirements: Maple 6 and later, Internet Explorer 4.01 and later, or Netscape 4.08 and later.

Load the JavaViewLib Package

To load the JavaViewLib package you generally need to point Maple to the directory in which you have unzipped the JavaViewLib archive, and use the `with` command to load it as Maple package.

> restart:libname;

Depending on your operating system (Unix or Windows) choose either of the following styles to specify the location of the JavaViewLib installation.


> installationPath:="/tmp/JavaViewLib/":


DOS/WINDOWS (adjust to your Maple version!!!):

> installationPath:="c:\\Programme\\Maple 6\\JavaViewLib\\":

Prepend the JavaViewLib installation path to the library name. This allows Maple to find JVL.

> libname:=installationPath,libname;

Load the JavaViewLib using the with command.

> with(JavaViewLib);

First check: Launch JavaView. If JavaView fails go to section Trouble Shooting at the bottom of this worksheet.

> runJavaView();
JavaView-Lite Shortcuts
Left-Mouse Drag to rotate
s Drag to scale
t Drag to translate
r Switch to reset
w / q Start / Stop auto-rotation
Shift-s Smooth drawing (slow)
Shift-z Enable z-buffer when surfaces intersect
Right-Mouse Show popup menu
More ... JavaView Help


At this point you should be able to view the help browser information on the JavaViewLib. Note that [> ?JavaViewLib or [> ?JavaView may be used equivalently at the Maple command prompt.

> ?JVL

Important points to note:

Maple requires package names and elements of the libname to be case sensitive.

To verify that JVL loaded successfully, do not repress the output of the with command, and ensure that the above line matches your own.

JVL will complain if the browsers you intend to use are not referenced in your path environment variable. Currently IE, NS, NS6, and Opera are supported.

To avoid having to execute these commands for every Maple session, include them in your Maple initialization file. A sample maple initialization file, maple.ini, is included with this archive for a Windows platform. Open it with a text editor change the JavaViewLib installation path to suit your own, and copy this file into the BIN.WNT directory of your Maple 6 installation, or the LIB directory of your Maple 7 installation. Unix platforms should place an initialization file named maple into the bin directory of thier Maple 6 installation, or one named .mapleinit in the lib directory of thier Maple 7 installation.

Basic Functionality

Assuming your installation was sucessful, you should be able to run the following commands. Each Maple plot is shown in a separate JavaView window as interactive geometry. JavaViewLib generates intermediate files and stores them relative to the installation directory respectively working directory unless full qualified filenames are specified.

Function curve in 2D.

> runJavaView(plot(cos(x) + sin(x), x=0..Pi));

Function plot in 3D.

> runJavaView(plot3d(2*sin(x)*sin(y),x=-Pi..Pi,y=-Pi..Pi));

Möbius strip is a parametrized surface in 3D.

> runJavaView(plot3d([4+x*cos(y/2),y,x*sin(y/2)],x=-3..3,y=-0..2*Pi,coords=cylindrical,grid=[10,40]));

The command runJavaView generates a temporary geometry file which may be re-imported into this worksheet as Maple plot.

> import(mpl/JVLExport.mpl);

> runApplet(plot([sin(4*x),x,x=0..2*Pi],coords=polar));

If you would rather not view your plots immediately, export them - perhaps modify them - and import them later.

> exportMPL(myPoly,plots[polyhedraplot]([0,0,0],polytype=TriakisIcosahedron)):

> import(myPoly);

More on runJavaView()

The JavaView standalone application is interfaced with Maple using the runJavaView() command. It contains the most complete compilation of the JavaView modules as web considerations need not be taken into account. This interface is provided for the use of JavaView on your local machine. The following function calls illustrate how to typically make use of this interface function.

Load a Maple animation into JavaView.

> plots[animate3d](2*sin(x+u)*sin(y),x=-Pi..Pi,y=-Pi..Pi,u=0..2*Pi);

> runJavaView(%):

You may also load geometric models of a various other formats into JavaView by simply providing the path to where it is located. If a relative path is specified it is with respect to your current working directory - see the section entitled 'Additional Functionality' for more information. Among others JavaView supports the .byu .fe .jvx .mgs .mpl .obj .off and .wrl formats.

> runJavaView("models/hand.obj");

If you would like to simultaneously save your plot object as a .mpl or .jvx file, provide the filename or fully qualified path to which to save as a secondary argument. By default the file will be exported as a .mpl file unless you explicitly add the .jvx extension to your filename. The following displays the plot object in the JavaView application while at the same time saving it down to the /jvx directory of your working path in the .jvx representation..

> a:=plots[polyhedraplot]([0,0,0],polytype=echidnahedron):

> runJavaView(eJVX.jvx,a);

You can load from or export to compressed geometry files by appending the .gz extension to the filename

> runJavaView(a,eMPL.mpl.gz);

Another common use of the JavaView standalone is to use it's modelling tools. In particular, you may generate an object procedurally in Maple, manipulate it in JavaView and import it back into Maple. Run the following command to import a simple box into JavaView and experiment with its modelling features. Hit ctrl-g to open the control panel and access the menus. Here we invoked the menu command METHOD=>EFFECT=>UNFOLD GEOMETRY to the box, saved it as a .mpl file in our models directory and imported it back into Maple.

> runJavaView(plots[polyhedraplot]([0,0,0],polytype=hexahedron),box.mpl);

> import(box.mpl);

> import(models/unfoldedbox.mpl);

More on runApplet()

Here we interface with the applet variant of JavaView, allowing one to access it's functionality in realtime over the internet. This function provides a uni-directional export of Maple plots to a 'skeletal web page' which can then be fleshed out to a final html document. Basically, runApplet combines the export* functions into a single interface function and automatically launches your browser as the container for the JavaView applet. If any .mpl, .jvx, or .htm  files are generated, they are output to the corresponding ./mpl, ./jvx, or ./htm subdirectory of your working path - see 'More on export*' for details. Currently Maple exports its plots to static images when you attempt to export your maple worksheet to html. This 'skeletal web page' simply contains the applet tag that embeds the JavaView applet into your web page, thus allowing for Maple plots to remain dynamic upon export.  Tags in general are directory structure dependent as they point to where the browser can expect to find the files with which to render the page. Therefore it is important to keep the structure maintained by JVL in your working path - relocating files would require you to manually adjust the tag's definition. On this note, you may wish to compress the JavaView data files using gzip or WinZip for quicker remote file transfer. This would require you to add the appropriate extension - i.e. mpl.gz or .jvx.zip - to the file referenced in the applet tag. The following function calls illustrate how to specify where and how to export your Maple plots to the web:

You can choose to export your Maple plot in one of 3 formats: .mpl, .jvx, or .htm. The default exports the plot to a single .htm file with the plot data embedded. In writing an html document that makes use  of the JavaView applet tag, you may wish to have a more concise representation. In this case you need to append the .mpl or .jvx extensions to your filename. After executing the following commands, view the html source. The file returned is the location where you can find the html file to open.

A sample Maple plot used in this section.

> a:=plots[tubeplot]({[cos(t),sin(t),0],[0,sin(t)-1,cos(t)]},t=0..2*Pi,radius=1/4):

Generate an interactive web page. The Maple plot is included inside the html page as applet parameter, no separate geometry file is generated.

> runApplet(a,rings);

Generate a separate geometry file and an htm page which references the geometry file.

> runApplet(a,_rings.mpl);

As the geometry files can be quite large, it is recommended to compress them before deploying to the web to increase loading time. This can be done by simply appending .gz to the filename.

> runApplet(a,_rings.mpl.gz);

JavaView-lite is a stripped down version of the JavaView applet optimized for quick load time which is primarily used for showcasing geometries.

> runAppletLite(a,_ringsLite.mpl);

Though not generally recommended, you may export to an arbitrary path. Keep in mind that the applet jar is also copied to this path. As such, only the light version (125KB) will be copied for both the runApplet and runAppletLite calls in order to minimize disk bloat. Note that JVL will automatically create non-existent directory structures, and that the '..' and '.' tokens can be used when specifying the directory path. Observe that 1 html page and the accompanying `jv_lite.zip` jar is copied to this directory. Specifying .mpl or .jvx in the filename extension instead of .htm (or no extension) would also provide the corresponding data file in this directory.

> runApplet(a,"tmp2/hihi/ring.htm");

If a single argument filename is given to runApplet, it will attempt to locate and open that file in the browser. Note that you must have a live internet connection to view the remote webpage.

> runApplet("http://www.javaview.de/maple");

> runApplet("http://www.cecm.sfu.ca/news/coolstuff/JVL/htm/webdemo.htm");

More on Export*

The functions exportHTM, exportMPL, and exportJVX are the three fundamental JVL export interfaces, providing three different contexts in which to export Maple plot data. The former allows one to quickly generate html pages equivalently to runApplet without browser preview, while the later two allow one to export just the data files for use in JavaView or other application. You can export Maple data in two formats: .mpl or .jvx. The .jvx format is a textual representation of the plot data and is the official file format for JavaView. Technically, this is an xml file which organizes the data using tags in a similar manner to html - you can use runMarkupTree to view it. The.mpl format more closely resembles that in which Maple stores it's plot data. This is a more compact representation resulting in a smaller data file size, on the other hand it is not as legible as a .jvx file. Before demonstrating typical usage of the export* interface, let us define plot object with which to work.

> box:=plots[polyhedraplot]([0,0,0],polytype=hexahedron):

The exportHTM interface is used to generate and couple html pages with your exported Maple plots. This can be done in one of two ways: 1) embed the data within the html page itself, or 2) link to data kept in another file. Note here that the ordering of arguments does not matter, that you must input absolute paths as strings, and that you must explicitly indicate that you wish to link to an external file by appending the appropriate extensions to the filename. If no filename is specified, the default handling will embed the data in a file named JVLExport and export it to the /htm directory of your working path. If a filename is specified without an extension it will be exported as embedded htm to the /htm directory. If a filename is specified with a .mpl ( .jvx ) extension the data file will be exported to the /mpl ( /jvx ) directory and an html page of the same filename exported to the /htm directory. Notice the return value always points to where you can find the html file, even when an arbitrary path is specified. Note: when specifying an arbitrary directory in which to export, you must terminate the string with a slash, otherwise the final token will be interpreted as a filename.

> exportHTM(box);

> exportHTM(box,"box.html");

> exportHTM(box,mplBox.mpl);

> exportHTM(box,jvxBox.jvx);

> exportHTM(box,"tmpHi\\");

The exportMPL interface is used to export nearly all of the visual qualities of the Maple plot. Javaview interprets most of the plot attributes, but selectively discards others. As this function only exports in the .mpl format, no extension qualification is needed. In fact, if specified, JVL will strip the extension and append .mpl. Note: if you have already exported to an mpl file of the same name - as we are doing here - that file will be overwritten.

> exportMPL(box,mplBox.jvx);

> exportMPL(box,mpl);

The exportJVX interface is used to export a crude representation of the Maple plot. The geometric data is exported in format that is easy to read and understand. The display can easily be embellished by adding additional jvx tags and attributes. A list of these may be found at www.javaview.de. As this function only exports in the .mpl format, no extension qualification is needed. In fact, if specified, JVL will strip the extension and append .jvx. Again, files can be compressed on export by appending the .gz extension to the filename.

> exportJVX(box,"tmp/tmp.jvx.gz");

> runApplet("tmp/tmp.jvx.gz");

Additonal Functionality

This extension describes a few additional features provided by the JavaViewLib to allow your html pages to be built quickly and easily.

The first important function is the set command. With this you can specify how you would like to render the applet and configure JavaView. Currently the list of attribute is small and can be identified by calling the getInfo command.

> getInfo();

JavaViewLib State Information


[W ]  Applet Width      | 200

[H ]  Applet Height     | 600

[A ]  Applet Alignment  | left

[R ]  AutoRotate        | show .5 .75 1.

[X ]  Axes              | show

[BC]  Background Colour | show 134 234 0

[BI]  Background Image  | hide images/jvlLogo.gif

[B ]  Border            | hide

[BB]  Bounding Box      | hide

[V ]  Camera Direction  | hide 1. 2. 3.

[DC]  Depth Cueing      | hide

[EA]  Edge Aura         | hide

[BG]  HTML bgcolor      | 255 255 255

[PT]  Show jvx Points   | hide small

[ED]  Show jvx Edges    | hide

[FC]  Show jvx Faces    | show

[T ]  Title             |

[WK]  Working Path      | c:\Programme\Maple 6\JavaViewLib\

[IP]  Installation Path | c:\Programme\Maple 6\JavaViewLib\

[OS]  Operating System  | Windows NT/2000

[BR]  Browser           | iexplore

[JV]  JavaView Runtime  | bin\javaview.bat

[DG]  Debugging         | false

A sample Maple plot used in this section.

> plQt:=plots[tubeplot]([- 22*cos(t) - 128*sin(t) - 44*cos(3*t) - 78*sin(3*t), 11*cos(t) - 43*cos(3*t) + 34*cos(5*t) - 39*sin(5*t) , 70*cos(3*t) - 40*sin(3*t) + 8*cos(5*t)- 9*sin(5*t), t=0..2*Pi],radius=10,tubepoints=12,numpoints=100):

> runApplet(plQt,plQtStandard.htm);

Notice that JVL allows you to specify a small set of preconfiguration parameters to deviate from the default view. For instance, here we make the applet viewport a vertical band and of a different color, and turn on the viewer's axis.

> set(width=300,height=500,bc="134 234 0",axes=on,align=left,dc=on,rotate=".5 .75 1.");

> runApplet(plQt,plQtConfig.htm);

Select your preferred browser. Possible options are IE, NS, OP, FF for Internet Explorer, Netscape, Opera and FireFox. Note, JVL search for names such as netscape, netscp6, netscp, opera and firefox in your PATH environment variable which MUST BE SPECIFIED outside of this worksheet.

> set(BR=FF);

[_FF, "firefox", 1, 0, 0, 1, 0, 1]

Adjust applet parameters and other JavaViewLib state variables.

> set(w=200,h=200,r=yes,bg=image,axes=off,align=left):

> runApplet("models/hand.obj");

One of the niceties of  JVL is that it allows you to quickly 'hotswap' the static plot images of a Maple html export with the dynamic applet renderings of JavaView. Ideally JVL would be able to parse the entire .mws and do the hotswap automatically, but Maple restrictions do not allow for this. As a workaround, you can use the genTag command to provide the tag for you to cut and paste directly into your Maple html exports. Simply export your worksheet to the /htm directory of your working path, run genTag, open the Maple generated .html file and search for "<IMG". If what follows is the text "[MAPLE PLOT]", just cut and paste the output of genTag in its place. This command works identical to runApplet, except the text is output to Maple instead of launching a browser.

> genTag(plQt,knQt.mpl);

<APPLET CODE='javaview.class' ARCHIVE='jars/javaview.jar,jars/jvx.jar' CODEBASE='..'


<PARAM NAME='DepthCue' VALUE='show'>

<PARAM NAME='Background' VALUE='134 234 0'>

<PARAM NAME='Border' VALUE='hide'>

<PARAM NAME='AutoRotate' VALUE='show'>

<PARAM NAME='RotDir' VALUE='.5 .75 1.'>

<PARAM NAME='Model' VALUE='maple/gettingStarted/mpl/knQt.mpl'>


JVL provides a feature that allows one to quickly generate publishable html collections of exported Maple plots. The viewGallery will build a frames-based gallery of all the current .htm files in your working path, with a table of contents that points to them.

> viewGallery();

Current Working Directory (Maple 6 and 10, not Maple 9)

It is often useful that - prior to exporting a large quantity of files - you define a working path. Here JVL will automatically copy the necessary jars and establish a proper directory structure to which subsequent exports will be organized and built relatively. Here we set our working path to c:\tmp\jvlExport and export an html file with embedded plot data. The exported file will be found in c:\tmp\htm. You may want to modify this path accordingly.

Note: since '.' is the Maple concatenation operator, you must wrap quotes around the filename to distinguish the difference - otherwise your filename will be mixed with the Maple plote structure!

> setWorkingPath("c:\\tmp\\jvlExport");

> dode:=plots[polyhedraplot]([0,0,0],polytype=dodecahedron):

> exportHTM(dode,"htm/dode.htm");

> runApplet("htm/dode.htm");


At first, read the file readme.txt which accompanies every JavaViewLib installation.

Switch on debugging information: set(DEBUG=true). Many more hints and checks are provided in the new debugging workshop jvDebug.mws.

The following is a list of potential hazards, idiosyncrasies', behaviours, commonly encountered problems, and suggested remedies:

Filenames cannot start with a number.

On DOS/Windows, you need to escape backslashes when specifying path names with a backslash: \ => \\

When exporting a file, choosing a filename that already exists will overwrite the existing file.

Maple may be blocked when you execute runJavaView or runApplet. Closing the launched window will remedy this block.

Internet Explorer provides support for viewing xml markup trees. Netscape is lacking in this regard and will likely display poorly or attempt to launch JavaView.exe

Note that the  '~' operator for directory navigation is not handled by and cannot be resolved by JVL; an error will be raised if used.

Use Shift-Ctrl-X to quickly kill a JavaView session.

On Windows, use Alt-F4 as a quick way to kill your browser window.

If commands like runJavaView fail then switch on debug mode where information about the launching process is displayed.

> set(DEBUG=true);

> runJavaView();

launch(_JAVAVIEW): "bin\javaview.bat  "


If you encounter any installation problems or think you may have found a bug, please contact


© 1997-2017 Last modified: 22.06.2017 --- www.javaview.de --- The JavaView Project