Compiling and Running a Java Application

You can compile and run the Java application using JAR files from the MapR Maven repository or from the MapR installation.

Using JARs from the MapR Maven Repository

MapR Development publishes Maven artifacts from version 2.1.2 onward at http://repository.mapr.com/maven/. When compiling for MapR 6.1, add the following dependency to the pom.xml file for your project:

<dependency>
   <groupId>org.apache.hadoop</groupId>
  <artifactId>hadoop-common</artifactId>
  <version>2.7.0-mapr-1808</version>
</dependency>

This dependency will pull the rest of the dependencies from the MapR Maven repository the next time you do a mvn clean install.The JAR that includes the maprfs library is a dependency for the hadoop-common artifact.

For a complete list of MapR-provided artifacts and further details, see Maven Artifacts for MapR.

Using JARs from the MapR Installation

The maprfs library is included in the hadoop classpath. Add the hadoop classpath to the JAVA classpath when you compile and run the Java application.

  • To compile the sample code, use the following command:
    javac -cp $(hadoop classpath) MapRTest.java
  • To run the sample code, use the following command:
    java -cp .:$(hadoop classpath) MapRTest /test