MarvinSketch Example 1.1
The traditional way to put the MarvinSketch/AWT applet to a web page is by writing the following text in the HTML:
The<applet CODEBASE="../.." ARCHIVE="marvin.jar" CODE="MSketch" WIDTH=460 HEIGHT=380> <strong>(YOU CANNOT SEE A JAVA APPLET HERE)</strong> </applet>
CODEBASEoption 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
ARCHIVEoption is needed to speed up the downloads. The program code is packaged into a compressed JAR file,
marvin.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.
MarvinSketch/Swing has the same applet tag with minor differences:
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
<embed> for Netscape or
<object> for Microsoft.
There are 6 possibilities overall:
<applet ARCHIVE="marvin.jar">and AWT
<applet ARCHIVE="jmarvin.jar">and Swing
marvin_gui. These settings 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", the gui parameter is "
awt" or "
swing". You can try it by appending "
?jvm=plugin&gui=swing" or "
?jvm=builtin&gui=awt" 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.