The traditional way to put the MarvinSketch applet to a web page is by writing the following text in the HTML:
The<applet CODEBASE="../.." ARCHIVE="jmarvin.jar" CODE="JMSketch" WIDTH=540 HEIGHT=480> <strong>(YOU CANNOT SEE A JAVA APPLET HERE)</strong> </applet>
CODEBASE
option specifies the directory of
the Marvin binaries relative to the HTML file. This HTML file is in a
subdirectory of the Marvin binaries directory, that's why we use
"../..
" here.
The ARCHIVE
option is needed to speed up the
downloads. The program code is packaged into a compressed JAR file,
jmarvin.jar
.
The text "(YOU CANNOT SEE A JAVA APPLET HERE)" is
displayed if someone tries to see the web page with a browser that is not Java
compatible.
If you want your page to work with Sun's Java Plugin, then the situation
becomes more complicated, because instead of the standard
<applet>
tag, you have to use platform dependent
solutions, <embed>
for Firefox (mozilla) or
<object>
for Microsoft Internet Explorer.
There are 3 possibilities overall:
<applet ARCHIVE="jmarvin.jar">
<embed>
<object>
The JVM (built-in or Java Plug-in) have a default value based on your browser and Java version. If you want to use a different configuration, you have to specify the<script LANGUAGE="JavaScript1.1" SRC="../../marvin.js"></script> <script LANGUAGE="JavaScript1.1"> <!-- // marvin_jvm = "builtin"; // "builtin" or "plugin" msketch_begin("../..", 540, 480); // arguments: CODEBASE, WIDTH, HEIGHT msketch_end(); //--> </script>
marvin_jvm
. This setting can also be overridden by writing
CGI-like parameters in the URL of the page:
The jvm parameter is "<a HREF="sketcherpage.html?jvm=plugin&gui=swing">click here!</a>
builtin
" or "plugin
".
You can try it by appending "?jvm=plugin
"
or "?jvm=builtin
" to the URL of this page and
then loading it again.Note that in some browsers (such as MSIE) this method does not work if the
page is on a local drive, because document.location.search
is an
empty string. But if you put the HTML file and the applet on a web server,
then it should work.
The next example introduces the use of applet parameters.