Getting Started
Requirements
- version 1.5.0 or newer of the Java Development Kit. There have been issues with Eclipse and Java 7.
- Version 3.6.x of Eclipse (Helios). Either "Classic" or "Eclipse for Java Developers"
- Version 3.7.x of Eclipse (Indigo). (experimental support)
Installation
The Scala IDE for Eclipse is best installed (and updated) directly from within Eclipse.First follow the navigation path "Help → Software Updates ... → Available Software" then click the "Add Site..." button.
Choosing what version to install
All update sites for installation are at http://download.scala-ide.org/. The constellation of versions can be daunting at first. Read this paragraph to make an informed choice.The Eclipse plugin comes with a Scala compiler and Scala library. In a given Eclipse installation there can be a single version of the Scala plugin for Eclipse, so you need to decide what Scala version you are going to use. In other words, the choice of Scala version (2.8.x, 2.9.x, etc) is not per project, but per Eclipse installation.
Scala IDE for Eclipse supports three versions of the Scala compiler:
- 2.9.x supports projects using Scala 2.9.1 or 2.9.0-1. This is the currently release version of Scala, so you should choose this if you are unsure.
- 2.8.x is a backwards compatible version for projects using Scala 2.8.1 or 2.8.2.
- 2.10 is a build relative to Scala trunk. Choose this if you want the bleeding edge, or working on scalac itself
- 2.0 is a stable branch for the upcoming 2.0 release. We release nightlies and betas. Choose the latest beta for 2.9 if you are unsure what to install.
- 2.1 is the upcoming 2.1 release. It will be less stable and contain more features.
Tutorial
Here's a short tutorial how to create a "Hello
World" application with Eclipse. It assumes that you have installed the
plugin as described above and switched to the Scala perspective (Window → Open Perspective → Other → Scala then click"OK").
- Create a new Scala project "hello"
- First click the "New → Scala Project" item in the "File" menu.
- Enter "hello" in the "Project name" field.
- Click the "Finish" button.
- Create a new Scala package in source folder "src"
- Right-click on the "hello" project in the "Package Explorer" tab of the projects pane.
- Select the "New → Package" menu item.
- in the "New Package" window, enter "hello" in the "Name" field.
- Press the "Finish" button.
- Create a Scala object HelloWorld with a main method
- First expand the "hello" project tree and right-click on the "hello" package
- Select the "New → Scala Object" menu item and enter HelloWorld in the "Object name" field.
- Press the "Finish" button.
- Extend the code to print a message
- Make the HelloWorld object implement the main method and add a println statement (see image, below).
- Create a Run configuration for the Scala project
- Right click on HelloWorld.scala in the Package Explorer,
- Select "Run as ..." and select "Scala Application"
- Select the first matching item, the "HelloWorld" class.
- Click the "Ok" button.
0 comments: on "Scala IDE for Eclipse"
Post a Comment