Step by Step of Building Scala SBT project on Intellij

HI guys,

Let’s talk about the 1st topic here about how to build a simple sbt project in intellij. Actually, I am a hardware engineer, so I will use newbie level terms and feel free to skip these if you are already a senior guy.

Although I have to admit that Maven (a java built tool) and Gradle are quite powerful build tool, the Apache recommend using sbt to build project. Thus, let’s build sbt project, which we can program some Scala code for the Apache spark project based on.

Platform versions

OS:win7

Java: jdk.1.8.0_45

Scala:2.11.7

Intellij: community 14.1.4

spark:1.4.0

1. Install the Java idk

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

and set the Java_home like the following image shows up.

1

Type cmd in your menu->search window and type

java -version 

It should show up the java version.

11

2. Install the intellij

Intellij is a powerfull developing IDE, which is similar to Eclipse which most of you may heard of. However, Intellij has better support for Scala and Android development. So we choose Intellij here.

Please download and install it here,

https://www.jetbrains.com/idea/download/,

you might want the free community version, which is enough for us.

3. Build Hello world sbt project

After you installed the intellij, when you first opening it. The latest version 14.1.4 will let you choose to install scala plugin . Go select it. Open intellij and let’s build a simple sbt project without spark to testify your installation is correct.

4. Choose a sbt project

2

5. Name the project

3

6. Add the source code under src/main/scala/

5

7. Type in our first Scala App

7

8. Run the code

8

9. Let’s see the result

9

10. Sometimes we may encounter version issues, java missing class issues, among which might be resolved by cleaning Intellij cache. But remember to save files before cleaning cache

10

Congratulations, we have finished our first Scala App in Intellij!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s