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

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.

主站蜘蛛池模板: 广西| 新和县| 长寿区| 庄河市| 桓台县| 济南市| 凤台县| 三门峡市| 祁东县| 甘洛县| 公安县| 开江县| 内黄县| 诸城市| 曲沃县| 凤冈县| 平泉县| 普安县| 玉林市| 灵璧县| 甘谷县| 许昌市| 瓦房店市| 通州区| 青神县| 南通市| 贞丰县| 孟连| 上饶县| 山阳县| 富阳市| 武威市| 尼勒克县| 长丰县| 枞阳县| 老河口市| 丰台区| 昌乐县| 鸡西市| 明光市| 黑山县|