Fork me on GitHub

Overview

Force Field X (FFX) integrates OpenMM through a set of Java classes that are analogues of the OpenMM C++ API. This module documents how to depend on, initialize, and use the Java wrappers for OpenMM within FFX or your own Java projects.

Lower-level wrappers around the C API are automatically generated using Jnaerator and are available on GitHub: Java Wrappers for the OpenMM C API (jopenmm).

Maven Dependency

Include the OpenMM Java wrappers via Maven. The fat artifact bundles the native binaries and plugins for common platforms to simplify setup:

Dependency


          
<dependency>
  <groupId>edu.uiowa.jopenmm</groupId>
  <artifactId>jopenmm-fat</artifactId>
  <version>8.3.4</version>
</dependency>
          
        

For advanced users interested in slimmer artifacts or platform-specific binaries, see the jopenmm project page.

Initialization and Plugins

Before using any OpenMM APIs, initialize the library with OpenMMUtils. This extracts the bundled native libraries to a temporary directory and configures JNA to find them:


OpenMMUtils.init();
      

To load OpenMM libraries and plugins (e.g., for additional platforms or forces):


String libDirectory = OpenMMUtils.getLibDirectory();
StringArray libs = Platform.loadPluginsFromDirectory(libDirectory);
String pluginDirectory = OpenMMUtils.getPluginDirectory();
StringArray plugins = Platform.loadPluginsFromDirectory(pluginDirectory);
      

To create a platform instance, use the Platform class.


Platform platform = new Platform("CUDA");