Compiling and Running MapR Database Binary Applications

For applications that use the MapR Database Java API for binary tables, use Maven to compile and determine the application's dependencies. Then, when you run the application, specify those dependencies in the application's classpath.

Compile and Determine Dependencies

  1. Add MapR's maven repository to the list of repositories in your application's pom.xml, if it is not there already:
  2. Add a dependency to the HBase client project:
      <version><version selected from the repository></version>
    • The hbase-client version mentioned above is an example. The actual version that your application requires is based on the current MEP and MapR version that you are running.The file versions are listed in the following location: Ensure that the version tags include reference to m7-<maprversion>. Otherwise, your applications will not be able to access MapR Database binary tables.
    • If your application uses both the MapR Database JSON and MapR Database Binary APIs, you may encounter a conflict in the netty library used by each API. To avoid this, exclude the netty library from your hbase-client dependency as follows:
         <version><version selected from the repository></version>
  3. Use Maven to compile the application and resolve dependencies. For example, you can run mvn clean package.

Running Applications

When you develop a Java application, you can use a dependency management tool such as Maven to compile your application. However, it is recommended that do the following instead:
  1. Compile the Java application without including dependencies
  2. Specify the required classpath when you submit the application to the cluster
If you choose to bundle the JAR file, and there is a mismatch between the bundled JAR file and the version that your MapR cluster expects, this can result in failures. The failures differ depending on the version of MapR you are using. For more information, see Using the MapR Filesystem JAR to Connect to the Cluster.

If the cluster is secure, the node must also have a mapr ticket configured for the user that runs the application.

You can use the following command to launch MapR Database binary applications:
java -cp <classpath>:. -Djava.library.path=/opt/mapr/lib <main class JAR> <command line arguments>
Note: The classpath should include items that are part of the 'hbase classpath' script plus any other required dependencies.