Scala Plugin for Eclipse
The Scala plugin for Eclipse is centered around seamless integration with the Eclipse Java tools, providing many of the features Eclipse users have come to expect including,
- Support for mixed Scala/Java projects and any combination of Scala/Java project dependencies. Type driven operations are transparent across Scala and Java files and projects, allowing straightforward references from Scala to Java and vice versa.
- A Scala editor with syntax highlighting, inferred type and scaladoc hovers, hyperlinking to definitions, code completion, error and warning markers, indentation, brace matching.
- Project and source navigation including Scala support in the Package explorer view with embedded outline, outline view, quick outline, open type, open type hierarchy.
- Incremental compilation, application launching with integrated debugger, hyperlinking from stacktraces to Scala source, interactive console.
- Support for Eclipse plugin and OSGi development including hyperlinking to Scala source from plugin.xml and manifest files.
The plugin is released under a BSD-like license and community involvement in its development is strongly encouraged. See the developer documentation here.
Requirements
The recommended (and minimum) versions of the components required to use the Scala Eclipse plugin are,
- version 6 or newer of the Java Development Kit (minimum version 5)
- version 3.4 or newer of Eclipse "Classic" (minimum version 3.3 with slightly reduced functionality)
Installation
The Scala Plugin 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 to get to the following dialog,
Adding the Scala update site
Enter this URL in the "Location" field and click the "OK" button:
http://www.scala-lang.org/scala-eclipse-pluginYou should then see "Scala Eclipse Plugin" offered for installation. Click on the "Install ..." button and follow the instructions from there.
If you have projects created using earlier versions of this plugin, including recent pre-release versions, then you might need to modify them before they will build correctly.
All newly created projects will be correctly configured, so if this is your first use of the Scala Eclipse plugin, please skip to the next section.
For each older project please check the following,
- The .project should be of the following form,
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Project name</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>ch.epfl.lamp.sdt.core.scalabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>ch.epfl.lamp.sdt.core.scalanature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
- The .classpath should be of the following form,
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src" />
<classpathentry kind="con" path="ch.epfl.lamp.sdt.launching.SCALA_CONTAINER" />
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER" />
<classpathentry kind="output" path="bin" />
</classpath>
- The per-project properties should be set as follows,
Here's a short tutorial how to create a HelloWorld 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 and 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 and select the "New → Package" menu item; in the "New Package" window, enter "hello" in the "Name" field and press the "Finish" button. - Create a Scala object "
HelloWorld" with main method
First expand the "hello" project tree and right-click on the "hello" package; then 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 theHelloWorldobject extendAppplicationand add aprintlnstatement to the console. - Create a Run configuration for the Scala Project
Select the menu item "Run → Run Configurations..." then double-click "Scala Application". Set the "Main class" tohello.HelloWorldand click the "Run" button.
Scala "Hello world!" in Eclipse
Feedback
You have several ways to provide your feedback on the Scala plugin:
- Send your suggestions and questions to the mailing-list scala-tools @ listes.epfl.ch.
- Contribute a bug report
- Rate this plugin @ Eclipse Plugin Central !
