Jmol Applet
- Jmol as a standalone application.
- J(S)mol as a web applet or HTML5 object.
- compatibility with JavaScript frameworks or libraries.
- J(S)mol embedded in wikis or blogs.
- Borrowed JSmol, or running JSmol without your own server.
- Running Jmol using Java Web Start.
- JSmol in a Jupyter notebook.
- Jmol in an Android tablet.
- Troubleshooting.
Contents
Jmol Applet
Java applet version of Jmol which allows Jmol to be embedded in web pages (given that viewers have a Java plugin installed). Like with the application, Scripting is available. For some demonstration pages see http://www.jmol.org/demo/. To see the HTML source use your web browser View → Page Source.
Installing Jmol Applet
If you only wish to create a web page(s) containing molecular scenes in Jmol, there are easier ways than starting from scratch: see #Tools for Authoring Jmol Web Pages. If you wish to learn how to create web pages containing Jmol from scratch, read on.
- Get the files from SourceForge.
- Support and operating systems.
- Users: how to install Jmol application for local, standalone use.
- Web page authors: how to install Jmol objects (Jmol / JSmol) embedded within your web pages.
- Installing and Enabling Java (Proteopedia wiki). Has step by step instructions for both Windows and Mac OS X, and for the 5 most popular web browsers.
- Increasing java memory for the applet.
- Web site administrators:
- How to install the application on a web server to be delivered using Java Web Start.
- How to configure a wiki so that it uses the Jmol applet.
- Developers: compile the latest Jmol source code via subversion access.
Download the Jmol package (either .zip
or tar.gz
format) and extract/uncompress only the necessary files to the folder of your choice.
Which are those necessary files? For basic use, these:
- Jmol.js, this contains a set of scripting commands that are helpful for interacting with Jmol via a web page (functions for buttons, checkboxes, etc. to interact with the applet). For an overview of functions see the online documentation or, for the most up-to-date info, just browse the Jmol.js sourcefile.
- All files whose name starts with JmolApplet0 and ends in .jar
- If you will distribute your web page files, you should also include the copyright, license and information files: COPYRIGHT.txt, LICENSE.txt and README.txt
To use JmolApplet within local web pages, e.g. on the hard disk or on CD, see Jmol Applet Deployment Local for some precautions needed.
For some specific needs, you must use other files; read the sections below about the signed applet.
If the applet does not load, see also Solving Java Problems.
Giving JmolApplet more memory to work with
Memory available to Jmol is determined by Java. You can check the current memory allocation by opening the pop-up menu in the applet, and the last submenu "About Jmol".
Less or more memory can be allocated by using this parameter:
-Xmx###M
where the ### must be substituted by a number in megabytes (hence the "M" after it). However, the amount of memory that can be allocated is limited by your existing RAM. For example, on a system with 512 MB RAM, a maximum of 256 MB is allowed for Java.
Examples:
- -Xmx512M will give 512 Mb maximum memory available.
- -Xmx1024M will give 1024 Mb maximum memory available.
The place to set this parameter is:
Windows
- Control Panel > Java icon (opens the Java Control Panel) > "Java" tab > "Applet run-time configuration" > "Show" button > on row "JRE" (latest version if there are several), click on the textbox under "Parameters" and type: -Xmx###M
Macintosh
- OS 10.5 (Leopard): Double click on JavaPreferences.app (in /Applications/Utilities). In the 'General' tab, select the first version of Java that is in the list. This will activate the 'Options' button: click it. A box for 'Applet Runtime Parameters' will open, where you can enter the -Xmx###M parameter.
- OS 10.4 (Tiger): Possibly look under /Applications/Utilities/Java/J2SE 5.0/Java Preferences, then look for the place to put the -Xmx###M
- Or look in the Java Control Panel.
Note that this is a local setting, so it will only affect that computer. You cannot expect that visitors of your web pages will have the same Java memory configuration as you, so be careful when using this feature.
Technical details:
- -Xmx sets the maximum memory heap size.
- -Xms sets the minimum memory heap size.
See also the procedure for the application.
Forcing JmolApplet to open in a certain language
JmolApplet includes several languages (technically called localizations) for the user interface (pop-up menu). JmolApplet will open by default with the interface using the language of your operating system (ref.). However, if you need to change this:
- Starting Jmol 11.1.30, the language in the applet can be switched anytime, from the pop-up menu, "Language" item near the bottom.
- Or, using the scripting language:
language = "de"
(you must use the keyword "language" and the two-letter language code: ca, cs, de, en, es, et, fr, nl, pt, tr) - This is an old method, only needed for versions below 11.1.30: If you want to force a certain language,
On Windows: Open Windows Control Panel > Java icon (opens Java Control Panel) > Java tab > Applet run-time configuration > Show button > on row "JRE", click on the textbox under "Parameters" and type:
java -Duser.language=es # forces Spanish (Español) java -Duser.language=de # forces German (Deutsch) java -Duser.language=en # forces English etc.On Macintosh: Open the Java Control Panel at /Applications/Utilities/Java/J2SE 5.0/Java Preferences and set the parameter as above.
See also the procedure for the application.
Testing different applet versions
(This is an advanced feature)
You can force the use of a certain version of Jmol applet in any web page (even if that page is not yours). The way to do so is:
On the URL line of the browser, add
?JMOLJAR=
followed by the url of the JmolApplet0.jar or JmolAppletSigned0.jar file your intend to use.
If there is already a ?
in the URL, then use &JMOLJAR=
, to preserve the logic of a url.
There will be a couple of warnings that you will have to accept, due to the potential security risk of replacing an applet with another coming from a totaly unrelated server. There may also be Java security issues still preventing the applet from loading files, unless you specify the signed applet.
For example:
http://www.rcsb.org/pdb/explore/jmol.do?structureId=1CRN&bionumber=1&JMOLJAR=http://chemapps.stolaf.edu/jmol/docs/examples-12/JmolAppletSigned0.jar
lets you use Bob's latest version of Jmol at the RCSB site (which is currently using 12.0.41, signed). Try it.
If you just want a change to the signed version of the same applet, this shortcut notation may be used (Jmol.js in 12.2.RC8 or later):
?JMOLJAR=SIGNED
(But note that the website author may have omitted the signed applet files in the server, so the applet will fail to load.)
Jmol in Wikis
The applet can be embedded in HTML (or XHTML) pages (examples are listed on Websites Using Jmol), but also, with some extra technologies, in Wiki pages (see Jmol Processor).
Unsigned vs. Signed Applet & Data Access
The signed applet can load a molecular model from any http or ftp URL. However, the user will be asked to trust the signed applet (figure at right). This could be problematic since the publishing authority (jmol.org) "cannot be verified", and the security certificate was issued by a group that is "not trusted" (jmol.org). This is because it would be costly and cumbersome for each version of the applet to be signed by a trusted (commercial) authority.
The unsigned applet displays the molecule without asking the user to trust it. However, it is limited (for security reasons) to loading molecular models from the same http domain (server) that downloads the applet itself. FirstGlance in Jmol uses the unsigned applet by default, but the signed applet will be used when that "Advanced Option" is checked. Thus you can easily see both applets in action. Methods for accessing data files from arbitrary servers are described in some detail at PDB Data File Access Methods.
If you are not running the applet from any server, i.e., you are using a web page residing in a local disk, further security restrictions are applied by Java: molecular models can only be located in the same folder/directory as the applet files or below it; read Jmol Applet Deployment Local.
Tools for Authoring Jmol Web Pages
Jmol.php: easy Jmol insertion into a web page
You can insert a Jmol applet into a web page with nothing more than a simple <script>
or <a>
tag.
You don't have to install any Jmol files in your computer or web server.
You don't even need a file with the 3D model; it will be automatically obtained from an appropriate web server.
Note that this way of using Jmol is easily compatible with any environment where you do not control the full source code, like forums, blogs, wikis, content management systems, e-learning environments... In fact, you can email the address and the recipient will see the Jmol applet by clicking on the received link.
See Jmol_PHP for details.
Proteopedia's Scene Authoring Tools
The easiest way to create, and share, a web page containing customized molecular scenes in Jmol, is to build the page in Proteopedia.Org. Proteopedia's Molecular Scene-Authoring Tools free you from learning any Jmol commands, HTML, or javascript. You will only need to learn a tiny bit of wikitext markup, for which convenience buttons and help are provided. On the other hand, if you already know some Jmol commands, you may use them in creating your scene (via the Jmol console). Regardless of how your scene is created, it will be saved as a Jmol state script. You may upload atomic coordinate files, or use published PDB files. Proteopedia automatically saves a frozen copy of each PDB file that you use, to protect your scripts from breaking e.g. after remediation of files by the Protein Data Bank. You may created pages that are protected from editing by others.
Jmol's Export to Web
If you are not comfortable writing html/xhtml and javascript code, or would just like to quickly put together some simple pages, then look at the export to web function of Jmol (available in version 11.4 and above). This allows you to export all the necessary files to make simple pages that have a number of live Jmol displays or a single Jmol display that can be changed by clicking buttons. You select the views you want the user to see by setting them up in Jmol. You then add any desired text or comments to the .html file created by the export function in your favorite web editor (Some open source suggestions: SeaMonkey is simple and works very well, Kompozer is more sophisticated and works pretty well, Amaya is the most sophisticated but is harder to use). Instructions for using the export function are accessible in the export to web dialog within the Jmol application. A more detailed tutorial and some older packages are available at Jmol Web Page Maker.--Gutow 21:48, 25 July 2008 (CEST)
Saving Files from the Applet
Although this isn't obvious, the molecule that is being shown in the applet can be saved to local disk (even from the unsigned applet). To do so:
- Open the applet's menu (right-click, Ctrl+click, or click on bottom-right "Jmol" logo).
- Click on the last entry (
About...
). - On the submenu that appears, click on the first entry (name of model).
- Then click on the last entry (
View
+ name of file) - Depending on your browser's configuration, the file will be opened in the associated program ("helper application") or you will get an "Open or Save" dialog; choose Save and location in your disk.
- In old Jmol versions:
- Open the applet's menu (right-click, Ctrl+click, or click on bottom-right "Jmol" logo).
- Click on topmost entry (name of molecule).
- On the submenu that appears, click on bottommost entry (name of model).
- Depending on your browser's configuration, the file will be opened in the associated program ("helper application") or you will get an "Open or Save" dialog; choose Save and location in your disk.
- Warning: At least in Windows, modern browsers may detect this action as opening a pop-up window, so it's likely that the pop-up blocker will prevent you from seeing the "Open or Save" dialog. Pay attention to messages and options in your browser to allow pop-ups for the current page. (Such messages often appear as yellow bars at the top of the page, warnings in a toolbar, or hints in the status line at the bottom of the browser window.)
- Note for Chime users: If you have MDL Chime installed, the molecule will be opened in a browser window using Chime. You just have to use Chime's menu (File > Save molecule as) to save the file to disk.
If the page uses the signed applet, there is a more intuitive and fully functional File
submenu near the bottom of the popup menu.
In addition to saving the full model, a part of the molecule can be extracted and saved into MOL format. This is not so straightforward as the former, and is described in the "interactive scripting documentation" (see Jmol home page).
It is also possible to save the state of the molecule (rendering style, coloring, visibility, orientation, etc.). See save state
and write state
in the Jmol scripting documentation. This gives similar functionality to what can be done in Chime or Rasmol, although due to Java security restrictions, saving to a file is not available for the unsigned applet. Instead, you get the data in the console, from where you can copy to a text editor and then save from that.
Contributors
AngelHerraez, GregE, EricMartz, Hansonrstolaf, Igor, NicolasVervelle, Gutow, Ted, Pimpim, Cudo29, Green