官术网_书友最值得收藏!

Installing IDE

There are several integrated development environment (IDE) tools that have support for Scala. JetBrains IntelliJ IDEA Community Edition is a great choice and has excellent Scala support.

Download and install JetBrains IntelliJ IDEA Community Edition (https://www.jetbrains.com/idea/download/) for your OS. Once the installation is complete, please follow these steps:

  1. Start IntelliJ IDEA Community Edition and accept all default suggested settings. It is always possible to back and change settings at any later point in time. Once this is done, you will see a screen similar to the following screenshot:


  1. Select Configure from the preceding screen (highlighted by red color arrow) and then select Plugins from the drop-down list. You will see a screen similar to the following screenshot:


  1. Install the Scala plugin by clicking Install from the screen aforementioned (highlighted by red color arrow). This action will download the Scala plugin and install it. Once this is completed, you will see a screen similar to the following screenshot:
  1. Now restart your IDE by selecting Restart IDE (highlighted by red color arrow). This will restart your IDE and make it ready for developing Scala code. Now you are ready to start using the IDE for writing Scala code.

Now let us create a sample Scala/SBT project called HandsOnScala by following the instructions at https://docs.scala-lang.org/getting-started-intellij-track/building-a-scala-project-with-intellij-and-sbt.html.

The following steps show how to create a new Scala-based SBT project:

  1. Click on Create New Project as shown in the following screenshot:
  1. Select on Scala and then click Next to move onto next step, as shown in the following screenshot:
  1. Make sure to select sbt as highlighted in the following screenshot:
  1. Specify a suitable name for your project. You also have the option of specifying the location where the project files will be stored on the local computer. By default, a folder in the home directory is selected as the project location. Please also note that you can select the following additional version details:
    • JDK version
    • SBT version
    • Scala version

In most cases, you can use the default versions, as shown in the following screenshot, press Finish button to continue:

  1. Add Scala Framework Support to the project (if it has not already been selected), as shown in the following screenshot. This is very important because, without Scala Framework Support, the IDE will not treat this project as a Scala project and will prevent any Scala-related work in the IDE:
  1. Just like in Java, the Scala source code is organized into packages. Create a package called handson.example by expanding to src/main/scala and right-clicking on the folder shown in the following screenshot:
  1. Now you are ready to start writing Scala source code and can run it on your IDE. Create and run your first Scala worksheet called HandsOnScratchPad, as shown in the following screenshot:

Scala worksheets are great tools for exploring and understanding Scala APIs. You can conveniently see the code and its associated evaluation side by side.

With the preceding IDE set up and running, you are now ready to work on any Scala project using the IntelliJ IDE. You also have the option of conveniently exploring small code snippets of Scala using the Scala worksheet feature of the IDE. This IDE also comes with a debugger and many more features that help improve a developer's productivity.

主站蜘蛛池模板: 新沂市| 嵩明县| 瓦房店市| 沧州市| 大新县| 鄂托克旗| 海兴县| 枣阳市| 托里县| 通化市| 库尔勒市| 嵊州市| 惠来县| 四川省| 巴青县| 宜兰市| 英吉沙县| 徐汇区| 桃园县| 报价| 景宁| 岐山县| 重庆市| 惠东县| 兰考县| 华安县| 渑池县| 古田县| 高淳县| 屏边| 双牌县| 临海市| 沧源| 额敏县| 九寨沟县| 兴业县| 兴化市| 普洱| 万山特区| 集安市| 绵竹市|