Free tutorials for Java, Eclipse and Web programming



Follow me on twitter

3. Your first Scala project

Tip

The current Eclipse scala plugin is still a little bit buggy in its current version. If you have strange syntax errors. Select Project -> Clean and select your project to force the Scala compiler to re-build your project.

To create a Scala application you define an object (which is the equivalent of an Singleton in Java ).

Create a new Scale project "de.vogella.scala.first" via File -> New -> Project ->Scala Wizards -> Scala Projects

Press finish.

Right click on the "src" folder and select New - Package and create the package "de.vogella.scala.first".

Create the new scala object "Hello.scala".

Tip

Would be nice to have the option to create a main method in this dialog. See Bug for: Option to add main method to new object dialog .

Change the source code to the following.

			
package de.vogella.scala.first;

  object Hello {
    def main(args: Array[String]) {
      println("Hello, world!")
    }
  }

		

Right-click your application, Select Runs -As -> Scala application and enjoy the output in the console.