---
title: "Install Aerospike Connect for Spark"
description: "Install Aerospike Connect for Spark: Prerequisites, artifact selection, and setup via JFrog or manual JAR files."
---

# Install Aerospike Connect for Spark

> For the complete documentation index see: [llms.txt](https://aerospike.com/docs/llms.txt)
> 
> All documentation pages available in markdown.

To create a Spark application that can access Aerospike Database, you have to download the appropriate connector JAR file and add it to your application’s environment.

## Aerospike Connect for Spark prerequisites

Before installing Aerospike Connect for Spark (Spark connector), verify that you meet the following prerequisites:

-   Your Spark cluster must be at version 3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x, 3.5.x, or 4.1.x.
-   The Java SDK must be installed on the system where you plan to run the Spark connector. Spark 4.1.x requires **Java 17**. Earlier Spark versions require Java 8. If you want to test with different Java versions, consider using [sdkman](https://sdkman.io) to help you manage those versions.
-   Your Aerospike Database Enterprise Edition cluster must be at version 5.0 or later if you plan to use the Spark connector version 2.0 or later.
-   The connector does not bundle Spark and Hadoop related binaries within its jar, which means your production system must have Spark and Hadoop installed.

### Java 17 module options for Spark 4.1.x

Spark 4.1.x on Java 17 requires JVM `--add-opens` and `--add-exports` flags on the driver and executors. Without them, date and timestamp operations can fail with `InaccessibleObjectException`.

Set `spark.driver.extraJavaOptions` and `spark.executor.extraJavaOptions` to the following value:

```text
--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/sun.nio.cs=ALL-UNNAMED --add-opens=java.base/sun.security.action=ALL-UNNAMED --add-opens=java.base/sun.util.calendar=ALL-UNNAMED --add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED
```

## Spark connector artifacts

You can download Spark connector artifacts from the [Aerospike downloads page](https://aerospike.com/download/connector/spark/) or from JFrog, under the [Scala 2.12](https://aerospike.jfrog.io/ui/native/spark-connector/com/aerospike/aerospike-spark_2.12/) and [Scala 2.13](https://aerospike.jfrog.io/ui/native/spark-connector/com/aerospike/aerospike-spark_2.13/) group paths.

Aerospike publishes multiple versions of the Spark connector for different combinations of connector version, Spark version, Scala version, and packaging type. The available packaging types are:

-   **allshaded** indicates that all internal libraries, including the Aerospike Java client, are bundled in the JAR.
-   **clientunshaded** indicates that all libraries except the Aerospike Java client are bundled in the JAR.

The following artifacts are available in JFrog:

| Connector version | Spark versions | Scala versions | Packaging types |
| --- | --- | --- | --- |
| **6.0.2** | 4.1 | 2.13 | allshaded, clientunshaded |
| **6.0.1** | 4.1 | 2.13 | allshaded, clientunshaded |
| **6.0.0** | 4.1 | 2.13 | allshaded, clientunshaded |
| **5.0.6** | 3.4, 3.5 | 2.12, 2.13 | allshaded, clientunshaded |
| **5.0.5** | 3.4, 3.5 | 2.12, 2.13 | allshaded, clientunshaded |
| **5.0.4** | 3.4, 3.5 | 2.12, 2.13 | allshaded, clientunshaded |
| **5.0.3** | 3.4, 3.5 | 2.12, 2.13 | allshaded, clientunshaded |
| **5.0.2** | 3.4, 3.5 | 2.12, 2.13 | allshaded, clientunshaded |
| **5.0.1** | 3.4, 3.5 | 2.12, 2.13 | allshaded, clientunshaded |
| **5.0.0** | 3.4, 3.5 | 2.12, 2.13 | allshaded, clientunshaded |
| **4.5.1** | 3.0, 3.1, 3.2, 3.3, 3.4, 3.5 | 2.12, 2.13 | allshaded, clientunshaded |
| **4.5.0** | 3.0, 3.1, 3.2, 3.3, 3.4, 3.5 | 2.12, 2.13 | allshaded, clientunshaded |
| **4.4.0** | 3.0, 3.1, 3.2, 3.3, 3.4, 3.5 | 2.12, 2.13 | allshaded, clientunshaded |
| **4.3.1** | 3.0, 3.1, 3.2, 3.3, 3.4 | 2.12, 2.13 | allshaded, clientunshaded |
| **4.3.0** | 3.0, 3.1, 3.2, 3.3, 3.4 | 2.12, 2.13 | allshaded, clientunshaded |
| **4.2.0** | 3.0, 3.1, 3.2, 3.3, 3.4 | 2.12, 2.13 | allshaded, clientunshaded |
| **4.1.0** | 3.0, 3.1, 3.2, 3.3, 3.4 | 2.12, 2.13 | allshaded, clientunshaded |
| **4.0.0** | 3.0, 3.1, 3.2, 3.3, 3.4 | 2.12, 2.13 | allshaded, clientunshaded |
| **3.5.5** | 3.0, 3.1, 3.2 | 2.12 | allshaded, clientunshaded |

Artifact filenames indicate the connector version, Spark version supported, Scala version, and packaging type. For example:

-   6.0.2-spark4.1-scala2.13-allshaded.jar
-   4.5.1-spark3.5-scala2.13-allshaded.jar
-   4.5.1-spark3.4-scala2.12-clientunshaded.jar

Spark 4.1.x artifacts use Scala 2.13 only. Apache Spark 4.x does not support Scala 2.12.

See the [Aerospike Connect for Spark release notes](https://aerospike.com/docs/connectors/spark/release-notes) for more information about each release. If you are upgrading to connector 6.0.0 or later on Spark 4.1.x, see [Upgrade to Aerospike Connect for Spark 6.0.0](https://aerospike.com/docs/connectors/spark/upgrade).

::: note
Although the Spark connector is tested with versions of Apache Spark, it should work with the Spark versions available in DataProc in Google Cloud Platform (GCP) and EMR in Amazon Web Services (AWS).
:::

## Spark connector installation

### Install using JFrog Artifactory

-   In `build.sbt`, add the JFrog resolver:
    
    `resolvers += "Artifactory Realm" at "https://aerospike.jfrog.io/artifactory/spark-connector"`
    
-   Add the dependency, SBT %% will select the correct Scala artifact, \_2.12 or \_2.13:
    
    `"com.aerospike" %% "aerospike-spark" % "<artifact-version>"` where `<artifact-version>` is the exact folder name in JFrog for the Spark version and packaging combination you want.
    

### Install manually

-   You can download the `.jar` package from the [Aerospike Downloads site](https://aerospike.com/download/connector/spark/).
-   Download the connector artifact that matches your Apache Spark and Scala versions. Connector version 6.0.0 or later supports Spark 4.1.x. Connector versions 4.0.0 through 5.0.x support Spark 3.x.

#### Add the .jar package to your application’s environment

You can do this in either of these ways:

-   If you plan to create a batch job or address the challenges of real-time business insights by leveraging the streaming job, write a Scala, Java, or Python application by following the interactive code in the [Jupyter notebooks](https://aerospike.com/docs/connectors/spark/tutorials/notebook). Specify the downloaded JAR as a dependency. Once your Spark application is ready, submit it to the Spark cluster using either `spark-submit` or `spark-shell`. See [Submitting Applications](https://spark.apache.org/docs/latest/submitting-applications.html) in the Spark documentation for detailed information.

**Example using `spark-submit`**

`spark-submit --jars path-to-aerospike-spark-connector-jar --class application-entrypoint application.jar`

-   If you plan to create a Jupyter notebook that uses the Spark connector, add the JAR path to the environment variables.
    
    **Example using Python**
    
    ```plaintext
    import os
    
    os.environ["PYSPARK_SUBMIT_ARGS"] = '--jars aerospike-spark_2.13-5.0.6-spark3.5-scala2.13-1-allshaded.jar pyspark-shell'
    ```
    
    **Example using Scala**
    
    ```plaintext
    launcher.jars = ["aerospike-spark_2.13-5.0.6-spark3.5-scala2.13-1-allshaded.jar"]
    ```
    

See our [notebooks](https://aerospike.com/docs/connectors/spark/tutorials/notebook) for other examples.