JSmol Deployment Local

From Jmol
Revision as of 11:27, 11 August 2025 by AngelHerraez (talk | contribs) (updates to remove methods for Java applet)
Jump to navigation Jump to search

This page summarizes some advice on how JSmol within web pages should be installed to work from a local disk (file:// protocol), instead of from a web server (http:// protocol).

This section is in relation to JSmol, Ver. 14.x, particularly. It only relates to HTML5 file access, and it relates only to files loaded using script commands such as load and script.

Note that you can prompt the page visitor for a local file by using the Jmol script command load ? or a URL using load http://?.

Specific browser considerations

Firefox / Windows

You will be able to read both binary and text files locally, but it is necessary to change the default setting:

  • navigate to about:config, find the security.fileuri.strict_origin_policy entry and set it false.

Chrome / Windows

The old method of starting Chrome using the command-line flag --allow-file-access-from-files for local file access is no longer possible. The only likely solution is to set-up a local web server.

It is not possible to load local binary files from standard script commands. That is, no direct file reading with any of the following in their names:

 .bin .gz .jmol .jpg .map .mrc .omap .png .pse .smol .spartan .zip

This does not apply to files drag-dropped onto JSmol or files loaded using "?", which use the HTML5 FileReader object. That method reads binary files without a problem.

Edge / Windows

Situation is the same as for Chrome (pending confirmation)

Opera / Windows

to-do

Firefox / Mac

to-do

Chrome / Mac

to-do

Safari / Mac

to-do


Rules for first-time user developing Jmol pages that will run from local disk:

Method (a)

Use pages only from a web server. For testing purposes, you may wish to install a local web server on your computer.

Method (b)

This works both locally and on the web server; depends on Java security rules, which might change in a future.
Update: recent versions of Java and browsers (particularly Firefox) apply a more restrictive policy, affecting also the location of html files -- A better description is planned; for now, see the graphic examples below. Note that the "unsigned" or "sandboxed applet (JmolApplet0xxxx.jar) is not usable for local deployment anymore. Instead, indicate true for the second parameter of jmolInitialize to request the all-permissions applet.

Molecule files (e.g. .pdb, .mol) must be in the same folder as the applet files or below it (in a subfolder).

Valid examples (see also graphic examples below):

1.- Put File icon.gifJmol.js and the set of File icon.gifJmolAppletSigned*.jar and File icon.gifJmolAppletSigned.jnlp files on the top folder level of your website; then, for a page in a subfolder:

<html>
  <head>
    <script type="text/javascript" src="../Jmol.js"></script>
  </head>
  <body>
    <script type="text/javascript">
      jmolInitialize("../", true);
      jmolApplet(200, "load caffeine.xyz");
    </script>
  </body>
</html>

2.- Same for a page in a subfolder two levels below:

<html>
  <head>
    <script type="text/javascript" src="../../Jmol.js"></script>
  </head>
  <body>
    <script type="text/javascript">
      jmolInitialize("../../", true); 
      jmolApplet(200, "load caffeine.xyz");
    </script>
  </body>
</html>

3.- Same as (1) but the model file is in a subfolder (named e.g. 'models') below the page itself:

<html>
  <head>
    <script type="text/javascript" src="../Jmol.js"></script>
  </head>
  <body>
    <script type="text/javascript">
      jmolInitialize("../", true); 
      jmolApplet(200, "load models/caffeine.xyz");
    </script>
  </body>
</html>

Method (c)

This works both locally and on the web server.

Use the "signed applet" files, File icon.gifJmolAppletSigned0*.jar, also included in the Jmol distribution download page

You can put applet files, model files and page files wherever you want to.

The users will receive a security warning from Java asking whether they accept the use of the signed applet (this may deter novice users from entering your pages, unless you first give them precise advice that this will show up and it is not harmful).

Examples of folder arrangement

This applies to running Jmol unsigned applet (File icon.gifJmolApplet0*.jar files) in local disks successfully (i.e. without Java security errors). Recent (June 2010) Java and browser security policies are considered in these examples.

If pages are run from a web server, any folder arrangement should work; these examples and explanations only apply to local disk.

Note: there are now reports that even from a web server some folder setups may raise Java security errors too. If so, please try activating UseCommandThread and share your findings in the email list.

Jmol parent, models same

No Problem.png These layouts give no problems.

P Folder yellow open.png   JmolApplet jar files
X Line42-down-branch-right.png Folder yellow open.png   html files, model and script files
C Line42-down.png Line42-down-right.png Folder yellow open.png
S Line42-down-right.png Folder yellow open.png
P Folder yellow open.png   JmolApplet jar files
X Line42-down-branch-right.png Folder yellow open.png
C Line42-down.png Line42-down-right.png Folder yellow open.png   html files, model and script files
S Line42-down-right.png Folder yellow open.png

Jmol parent, models child

No Problem.png This layout gives no problems.

P Folder yellow open.png   JmolApplet jar files
X Line42-down-branch-right.png Folder yellow open.png   html files
C Line42-down.png Line42-down-right.png Folder yellow open.png   model and script files
S Line42-down-right.png Folder yellow open.png

Jmol parent, models sibling

Warning.png This layout may be used from local disk, only if you activate UseCommandThread in your page (see details below). This may also apply to pages run from a server.

P Folder yellow open.png   JmolApplet jar files
X Line42-down-branch-right.png Folder yellow open.png   html files
C Line42-down.png Line42-down-right.png Folder yellow open.png
S Line42-down-right.png Folder yellow open.png   model and script files

Jmol sibling, models same

Error-Forbidden.png This layout cannot be used from local disk.

P Folder yellow open.png
X Line42-down-branch-right.png Folder yellow open.png   html files, model and script files
C Line42-down.png Line42-down-right.png Folder yellow open.png
S Line42-down-right.png Folder yellow open.png   JmolApplet jar files

Jmol sibling, models sibling

Warning.png This layout may be used from local disk, only if you activate UseCommandThread=true in your page (see details below). This may also apply to pages run from a server.

P Folder yellow open.png
X Line42-down-branch-right.png Folder yellow open.png   html files
C Line42-down.png Line42-down-right.png Folder yellow open.png
S Line42-down-right.png Folder yellow open.png   JmolApplet jar files, model and script files


Legacy documentation

Mainly involving use of Jmol Java Applets in web pages (not supported by current web browsers)

See the old version of this page.