- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Scala IDE for Eclipse
Created by milessabin on 2008-07-04.
Updated: 2009-10-30, 02:11
Important Upgrade Note (from version 2.7.3)
The Scala IDE 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 Scala IDE 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 1.6.0 update 14 or newer of the Java Development Kit (minimum version 5)
- version 3.5 or newer of Eclipse "Classic" (3.4.2 is supported but with caveats on read-only installations)
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 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-plugin
You should then see "Scala Eclipse Plugin" offered for installation. Click on the "Install ..." button and follow the instructions from there.
If you would rather do an offline installation there is an archive of the 2.7.7 release along with its MD5 sum.
There is another update site available for people wanting to follow development continuously:
http://www.scala-lang.org/scala-eclipse-plugin-nightly
please note that this is the bleeding edge, and we can't gurarantee that it will function correctly or at all.
Troubleshooting
If the Scala functionality appears to be non-functional after installing the Scala IDE and restarting Eclipse, in particular if Scala source files appear to be being interpreted as Java (with a consequently large number of "Java problem"s being reported against them, then please ensure that JDT Weaving is enabled by navigating "Preferences → JDT Weaving" then, if disabled, click the button to enable and follow the instructions to restart Eclipse. If this doesn't resolve your problem, check that JDT Weaving is still enabled after the restart. If not, please review the following section of this document ...
Use with read-only installations of Eclipse 3.4.2 or earlier
The Scala IDE can be added to a readonly Eclipse 3.4.2 installation, however this is fiddly and system dependent and upgrading to Eclipse 3.5 is recommened. If you are unable to do this, instructions for installing into a read-only or otherwise unusually laid out Eclipse can be found in the section "Installing JDT Weaving in a non-default location" of this guide.
Heap configuration
The default Eclipse heap configuration is often inadequate for the Scala IDE. It is strongly recommended that you edit your Eclipse eclipse.ini to add the following lines increasing various heap limits and VM options,
--launcher.XXMaxPermSize 256m -vmargs -Xms256m -Xmx1024m -XX:PermSize=64m -Xss1M -server -XX:+DoEscapeAnalysis -XX:+UseConcMarkSweepGC
The configuration above specifies a 1Gb maximum heap size. If the machine you are running the Scala IDE on has sufficient physical memory (eg. > 3GB) then specifying -Xmx2048m for a 2Gb heap might be beneficial.
It's no longer necessary to have per-projects settings for the Java builder (disabling output folder scrubbing and preventing the copying of .scala files to the output folder). It's not strictly necessary to remove these settings, but it's advisable. This should improve the behaviour of tools which generate Eclipse projects programmatically (eg. Maven).
There have been some minor changes to the way syntax highlight colour preferences are stored ... if things don't look quite as you'd expect then I recommend resetting them to their defaults and redo any customization you had previously.
There are persistent issues with dependency management which might show us after upgrading. If you experience hangs or extremely slow builds then I recommend locating and deleting the .manager folders that you will find at the top level of your Scala project. I expect this issue to be resolved in 2.8.0 which will make use of a significantly improved dependency management mechanism.
Important Upgrade Note (from versions earlier than 2.7.3)
If you have projects created using earlier versions of the Scala IDE 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 IDE for Eclipse, 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>
Note that there should not be a buildCommand entry for the Eclipse Java builder.
- 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>
Note the SCALA_CONTAINER entry and that it preceeds the JRE_CONTAINER entry.
Test Example
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 IDE for Eclipse:
- Send your suggestions and questions to the mailing-list scala-tools @ listes.epfl.ch.
- Contribute a bug report
- Rate this plugin @ Eclipse Plugin Central !
