Getting Started with Erlang
IntelliJ IDEA provides Erlang support. IntelliJ IDEA recognizes *.erl files, and allows you to edit them providing full range of coding assistance.
Install the required tools
Install the Erlang plugin in IntelliJ IDEA
In the Settings/Preferences dialog Ctrl+Alt+S, select Plugins.
Switch to the Marketplace tab and type
Erlangin the search field.
Once the plugin is found, click Install.
Appy the changes and close the dialog. Restart the IDE if prompted.
Install Erlang OTP
The first thing for setting up an Erlang environment is installing Erlang OTP, a set of Erlang libraries essential for development.
Install Erlang OTP using the instruction that corresponds to your operating system:
Download the Erlang OTP package and run the installation wizard.
Once the installation is over, add the installation path plus \bin to the PATH environment variable.
Run the following command in the terminal:
Run the following command in the terminal (make sure that you have the
apt-getutility):apt-get install erlang
To verify that Erlang OTP is installed correctly, run the Erlang shell by running
erlin the terminal:
For more information about the Erlang shell, refer to the Erlang documentation.
Install and configure Rebar
In addition to Erlang OTP, you’ll also need Rebar, a build tool that helps compile and test Erlang applications.
The easiest way to install it on your machine is to download its sources and build it locally:git clone git://github.com/rebar/rebar.git $ cd rebar $ ./bootstrap Recompile: src/getopt ... Recompile: src/rebar_utils ==> rebar (compile)
You now have a self-contained script called "rebar" in your current working directory. Place this script to a meaningful location so that you can use rebar to build OTP-compliant apps.
In the Settings/Preferences, go to and specify the path to Rebar, so that IntelliJ IDEA can run Rebar commands from the IDE.
Configure the Erlang SDK
One more thing you’ll have to do to configure IntelliJ IDEA is to add an Erlang SDK.
To do that, change the structure of the default project.
Open the default project structure in one of the two ways:
On the Welcome screen, go to .
From the main menu, select.
Add the Erlang SDK by specifying the path to the Erlang OTP installation directory.
If you don’t know where Erlang OTP was installed, check the following directories:
Windows: C:\Program Files\erl<version>
MacPorts, macOS: /opt/local/lib/erlang/<version>
Homebrew, macOS: /usr/local/Cellar/erlang/<version>
Create a new project
Create an Erlang project
There are several ways to create a new Erlang project. The easiest one is to use the Create a new project from the Welcome screen.
Click New Project:
Then choose Erlang in the left pane, and click Next.
IntelliJ IDEA prompts you to choose an Erlang SDK (which you've already configured):
After that you’ll be asked to specify the name of your project and its directory. The following image shows the resulting Erlang project with the name
Create a Rebar project
Instead of a pure Erlang project, you might want to create a Rebar project. To do that, type the following code at the Terminal prompt:
Once the project has been created, import it into IntelliJ IDEA to make it possible to open this project in the IDE.
Import a project into IntelliJ IDEA
You can import a project into IntelliJ IDEA in several ways. Let's explore importing from the Welcome screen.
On the Welcome screen, press Ctrl+Shift+A, type
project from existing sources, and click the Import project from existing sources action in the popup.
In the dialog that opens, select the directory in which your sources, libraries, and other assets are located and click Open.
IntelliJ IDEA offers you to either import the project from existing sources, or from an external model (a build file).
If your project uses Rebar, select the corresponding option when asked.
When importing a Rebar project, make sure to enable the option Fetch dependencies with rebar:
Run and debug an application
To run an application, you have to create a run/debug configuration created against the stub Erlang Application. To do this, on the main menu choose , select the stub Erlang Application, specify the name (here it is
hello.hello_world), and specify the application’s module and function:
After that you’ll be able to run your application via the main menu (, the toolbar , or a even a shortcut Ctrl+Shift+F10.
Once you have a run/debug configuration, you can also debug your application via the main menu (, the toolbar , or a shortcut Shift+F9:
Running Eunit tests
Running Eunit tests is similar to running an application, but needs a different run/debug configuration, created against the stub Erlang Eunit:
Running Rebar commands
Running Rebar commands is also possible right from the IDE – with the help of the Erlang Rebar run/debug configuration:
Note that if your Rebar commands run tests, you can use a Erlang Rebar Eunit run/debug configuration to see test results in a Test Runner.
Learning IntelliJ IDEA
IntelliJ IDEA is a Java IDE in the first place, however it’s also a platform and IDE for other languages, such as Erlang, Python, Ruby, PHP, and many other. To learn more about IntelliJ IDEA, it’s worth checking out the section IntelliJ IDEA overview and watch the Video Tutorials.
If you have a question, you can always ask it on StackOverflow (probably it’s already answered).
For information about contacting JetBrains support, see Getting started.