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

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.

主站蜘蛛池模板: 佳木斯市| 永昌县| 商城县| 胶南市| 天柱县| 江门市| 上高县| 宣城市| 安国市| 南涧| 松滋市| 明光市| 儋州市| 遂川县| 民乐县| 天柱县| 容城县| 洱源县| 清新县| 安义县| 江油市| 共和县| 舒城县| 勐海县| 梨树县| 资兴市| 藁城市| 聂拉木县| 芦溪县| 乌拉特后旗| 延川县| 墨玉县| 福海县| 伊通| 左云县| 宝山区| 德化县| 黑河市| 高邑县| 祥云县| 县级市|