From Jmol
Revision as of 19:54, 15 July 2011 by AngelHerraez (talk | contribs) (Copying code from the script console)
Jump to navigation Jump to search

Problems running the Jmol Applet in a web page

The applet does not show up

First of all, wait. Java may take time to load the first time, and the applet must be downloaded.

Yellow square with a message

  • Symptoms:

A yellow square is displayed in the place the applet should go, with a message inside.

  • Solution:

Read the message. Either you don't have Java installed, or the browser is configured not to use it. Enable Java for the browser or (re)install Java from Sun's site.

If you are certain that you have Java installed, there is a chance that the problem is related to certain incompatibility between browser (particularly Chrome under Windows) and Jmol versions; the fix is to update the Jmol version used by the page; read more.

Black square with an error

  • Symptoms:

A black square is displayed in the place the applet should go, with a message inside: Error. Click to get more information. When you click, a dialog opens:

Application error.
The application could not execute.
Click on 'Details' for more information.

When you click, the Java console opens:

load: class JmolApplet not found.
java.lang.ClassNotFoundException: JmolApplet
  • Solution:

Check if you have forgotten to include a call to jmolInitialize() in your page's source code. Instructions for using jmolInitialize() and the Jmol.js library.

Applet disappears in Internet Explorer 9

See Support/Windows#Jmol_pages_in_IE9

The applet is displayed, but models are not

First of all, make sure you have set the paths correctly for the model files (paths should be relative to the html page; in special ocasions you may also work with absolute paths).

If models still fail to load, open the Java console (instructions) and look for errors. Most often, the cause is a Java security restriction (keep on reading below).

Java security errors

Java imposes a security policy on applets, designed to avoid web pages to act on your local disk. This implies some restrictions on what files can be opened by the Jmol applet.

The Java security errors related to this will have a format similar to:

FileManager opening file:sample.mol
script ERROR: script ERROR: io error reading file:sample.mol: 
access denied ( sample.mol read)

The rule of thumb is:

  • When the page is run from a local disk, Jmol applet can only open files (load models and scripts) that are in the same folder or below where the applet File icon.gif.jar files are.
See explanation and examples of allowed and disallowed folder layouts
  • When the page is run from a web server, Jmol applet can only open files that are in the same server.
  • To overcome these limitations, you may use the signed applet, since that will request that the user explicitly gives permission.

See also Unsigned vs. Signed Applet & Data Access.

Models do not load in a Mac

Pages run from a local disk in a Mac may fail due to Java security errors when you use Firefox or other Mozilla/Gecko browser. You should use Safari on MacOSX for local pages. On the web, Mozilla browsers do work fine.

Explanation: Mozilla browsers on the Mac are known to pass local paths as absolute paths through the JavaScript calls. This causes a Java security exception when running locally.

The applet is displayed, other problems

Popup menu does not open and server errors (Fedora)

  • Symptoms::

Everytime a page gets to the 'jmolApplet()' stage, the httpd logs give lots of errors like:

File does not exist: /var/www/html/jmol-11.8.25/org

Also, Jmol pop-up menu doesn't open and gives more of the same errors in the server log.

  • Solution:

It was a problem with the browser (Firefox 3.5.9 on Fedora 11): Firefox was using the OpenJDK runtime environment and the associated IcedTea plugin. Installing Sun's Java and its plugin fixed the problem.


OpenJDK Java must be removed (yum whatprovides java will show you the precise versions to uninstall):

> sudo yum remove java-1.6.0-openjdk-plugin-
> sudo yum remove java-1.6.0-openjdk-

Then add the new plugin (the precise file to link may differ):

> cd ~/.mozilla
> mkdir plugins
> cd plugins
> ln -s /usr/java/jdk1.6.0_16/jre/plugin/i386/ns7/

Then open Firefox, select Tools > Addons, and enable the Java plug-in.

Applet does not respond to controls in page (Mac Safari)

This has been reported in Safari 5.0.1 on Mac OS X 10.6.4.

  • The page loads but the applet bails (literally the message bar says the applet bailed)
  • The applet loads but clicking on a link that should act on the applet does nthing. Safari may even crash.

The problem was tracked down to the AdBlock extension in Safari. Disabling the extension removes the problem.

Extracting information from the applet

Remember that the unsigned applet cannot read from or write to the local disk. Therefore, file operations are excluded; output cannot go to disk, only to the Script Console and/or the Java Console.

Copying code from the script console

Recent versions of Java (at least 1.6.0_24 onwards) prevent text output to Jmol Script Console to be copied and then pasted outside Java.

Possible workarounds for this:

  • Some output from Jmol is also displayed in the Java Console. From there, you can copy and then paste outside.
  • Select the text in the Script Console and, rather than copying it, drag and drop to a text editor.


AngelHerraez, Cudo29