Built with Tutify.io

    AIStudyLabs

    How to Run Spark Examples from IntelliJ

    How to Run Spark Examples from IntelliJ

    Here, I will explain how to run Apache Spark Application examples explained in this blog on windows using Scala & Maven from IntelliJ IDEA. Since the articles mentioned in this tutorial uses Apache Maven as the build system, we will use Maven to build the project.

    Make sure you have the following before you proceed.

    <a id="h-1-clone-spark-examples-github-project-into-intellij"></a>

    1. Clone Spark Examples GitHub Project into IntelliJ

    Let's clone Spark By Examples Github project into IntelliJ by using the Version Control option.

    Using this option, we are going to import the project directly from GitHub repository.

    
    https://github.com/spark-examples/spark-scala-examples.git
    

    Once the cloning completes, you will see the following project workspace structure on IntelliJ.

    <a id="h-2-run-maven-build"></a>

    2. Run Maven build

    Now run the Maven build. First, select the Maven from the right corner, navigate to Lifecycle > install, right-click, and select Run Maven Build.

    This downloads all dependencies mentioned in the pom.xml file and compiles all examples in this tutorial. This also takes a few mins to complete and you should see the below message after a successful build.

    <a id="h-3-run-spark-program-from-intellij"></a>

    3. Run Spark Program From IntelliJ

    After successful Maven build, run src/main/scala/com.aistudylabs.spark.SparkSessionTest example from IntelliJ.

    In case if you still get errors during the running of the Spark application, please restart the IntelliJ IDE and run the application again. Now you should see the below message in the console.

    Once you complete the running Spark sample example in IntelliJ, you should read what is Spark Session, what is Spark Context, Spark RDD, Spark RDD Actions, Spark RDD Transformations.

    <a id="h-related-articles"></a>

    Related Articles

    Happy Learning !!