Compiling and Running Applications that Access JSON Tables and Documents
You can compile applications that use the MapR-DB JSON API by using the required JAR file from the MapR Maven repository or from the MapR installation. Run applications with the mapr command.
- Using the JAR File from the MapR Maven Repository
-
NOTE: This method works only if your MapR cluster is not secure.
- Add MapR's Maven repository to your
pom.xml
file, if it is not already added:<repositories> <repository> <id>mapr-releases</id> <url>http://repository.mapr.com/nexus/content/repositories/releases</url> <snapshots><enabled>true</enabled></snapshots> <releases><enabled>true</enabled></releases> </repository> </repositories>
- Add a dependency to the
maprdb
project:<dependencies> <dependency> <groupId>com.mapr.db</groupId> <artifactId>maprdb</artifactId> <version>5.1.0-mapr</version> </dependency> </dependencies>
- Add MapR's Maven repository to your
- Using JARs from the MapR Installation
- Use the following command to compile
applications:
javac -cp `mapr classpath` <Application jars>
Launching Applications
Use the following command to launch applications:mapr <Main class jar> <commandline arguments>
NOTE: If
you want to add JAR files to the classpath that the
mapr
command uses, add
them with the environment variable MAPR_CLASSPATH
.
Example:
export MAPR_CLASSPATH=/home/apps/awesome-1.0.jar
mapr com.company.MyAwesomeApp