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 version 6.0.x, add the following dependency to the project's pom.xml file:

<dependency>
   <groupId>org.apache.hadoop</groupId>
  <artifactId>hadoop-common</artifactId>
  <version>2.7.0-mapr-1803</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.

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