JSmol Deployment Local
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://?.
Contents
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 thesecurity.fileuri.strict_origin_policy
entry and set itfalse
.
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 Jmol.js and the set of
JmolAppletSigned*.jar and
JmolAppletSigned.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, JmolAppletSigned0*.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 (JmolApplet0*.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
These layouts give no problems.
P | ![]() |
JmolApplet jar files | ||
---|---|---|---|---|
X | ![]() |
![]() |
html files, model and script files | |
C | ![]() |
![]() |
![]() |
|
S | ![]() |
![]() |
P | ![]() |
JmolApplet jar files | ||
---|---|---|---|---|
X | ![]() |
![]() |
||
C | ![]() |
![]() |
![]() |
html files, model and script files |
S | ![]() |
![]() |
Jmol parent, models child
This layout gives no problems.
P | ![]() |
JmolApplet jar files | ||
---|---|---|---|---|
X | ![]() |
![]() |
html files | |
C | ![]() |
![]() |
![]() |
model and script files |
S | ![]() |
![]() |
Jmol parent, models sibling
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 | ![]() |
JmolApplet jar files | ||
---|---|---|---|---|
X | ![]() |
![]() |
html files | |
C | ![]() |
![]() |
![]() |
|
S | ![]() |
![]() |
model and script files |
Jmol sibling, models same
This layout cannot be used from local disk.
P | ![]() |
|||
---|---|---|---|---|
X | ![]() |
![]() |
html files, model and script files | |
C | ![]() |
![]() |
![]() |
|
S | ![]() |
![]() |
JmolApplet jar files |
Jmol sibling, models sibling
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 | ![]() |
|||
---|---|---|---|---|
X | ![]() |
![]() |
html files | |
C | ![]() |
![]() |
![]() |
|
S | ![]() |
![]() |
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.