# Spark source code in IntelliJ IDE

This is a short tutorial on how to load the Spark source code in the IntelliJ IDE.

IntelliJ is very versatile, and offers many options that are not explored in this guide. Instead, this guide focuses on the bare minimum that is needed to get started.

## Prepare your environment

This guide assumes that you have IntelliJ installed, and have a copy of the source code available locally. Additionally, a Java Development Kit (JDK) should be installed.

Start by creating a new, empty workspace.

## Create a project and import the source code

The Spark source code is using an Apache Maven project structure. As IntelliJ recognizes this structure, importing the source code into an IntelliJ project is very easy.

Select the 'import' option. This will quickly import the Spark source code into a new IntelliJ project.

Creating a new project in IntelliJ.

Using the 'import' option, select the directory in which the Spark source code is stored. Select the Maven project file (pom.xml).

IntelliJ will automatically recognize and process the Maven structure of Spark, as soon as it is pointed to the correct directory. In most cases, You can accept the defaults on the following screens of the import wizard.

Use the 'import' functionality of IntelliJ to import the source code.

Once the import wizard has been closed, the IntelliJ workspace will show. There are menu bars to the left and right edge. Left edge, click "Project" to extend Project tree. On the right, click "Maven Project" to extend Modules. That's it! You're ready to start working on the code now!

Spark modules in the IntelliJ workspace

## Run Spark from IntelliJ

When developing, it is often useful to run the code straight from your IDE. The following will explain how you can start a Spark instance from the code that is in the IntelliJ workspace.

Run Spark straight from the source code.

The 'spark-core' module contains a class named `org.jivesoftware.Spark` that can be used to start Spark. Find the class in the Project Explorer, and open its context menu (right-click on the file). In that menu, use the 'Run Spark.main()' option. IntelliJ will start to build Spark from the source code, after which Spark itself is started. If everything goes well, you will see the Spark login screen within a matter of seconds! To see logs in the console you should specify VM option `-Ddebug.mode=true`.