An easy way to get started with Scala.
This project contains the minimum requirements to get started with Scala. Both command line REPL and compile/run mode are supported.
- For code changes see
src/main/scala/test/Main.scala
- To add libraries use
project/Build.scala
Several libraries are already in the Build file, from database drivers to PDF processing and Akka.
Mac, Windows and Linux build instructions are provided below.
Install Homebrew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install SBT:
brew install git sbt
Get these source files:
git clone https://github.com/csoma/Scala-starter.git
cd Scala-starter
Alternative: download as a ZIP
Start the command line REPL
sbt console
println("Hello!")
Ctrl-D will exit
Or run the included "Hello World" app
sbt run
- Maps and lists
- See also the "Scala IDE" below
- Download and install sbt. Choose MSI or ZIP.
- To use Git:
- Download and install git
- Get the sources:
git clone https://github.com/csoma/Scala-starter.git
- Or download as a ZIP
- Start REPL:
sbt console
- Build and run the app:
sbt run
- Ubuntu:
apt-get install sbt git
- RedHat:
yum install sbt git
- Get the sources:
git clone https://github.com/csoma/Scala-starter.git
- Start REPL:
sbt console
- Build and run the app:
sbt run
- src/main/scala/test/Main.scala - a minimal "Hello World" program
- project/Buid.scala - sets the project name, compiler flags, additional components like Scalatra and Postgres driver. Customize it to your needs.
- project/build.sbt - adds the "eclipse" command to sbt (sbt plugin)
Open the "project/Build.scala" file in the editor, find the "Additional components" section.
To enable a library just remove the comment from that line, like Scalaz, Postgres driver, Apache HttpComponent etc.
SBT will automatically download the specified library version and add it to classpath.
Any component supported by Maven can be added, see the "Component versions" section. The default repo list can be extended with the "ExtraResolvers" variable at the end of the file.
See the following links:
- Install Eclipse
- Install Eclipse Scala IDE plugin: http://scala-ide.org/
- In project/build.sbt enable the Eclipse plugin
- From command line run "sbt eclipse"
- Make sure the Scala perspective is selected
- From Eclipse use "Import Wizard" to import "General/Existing Projects into Workspace"
- Run now should have "Scala Application"
- sbt help - SBT (build tool) usage help
- sbt help tasks - available task list: clean, compile, run, package, test etc.
- sbt console-quick - starts the Scala REPL
- sbt console - starts the Scala REPL with the active project in the classpath
- sbt run - runs the active project (in this case just prints "Hello World")
- sbt eclipse - generate Eclipse project definitions
- sbt package - creates a JAR file in the "target" folder (size: about 1.5K)
- sbt - starts the SBT console
- Typesafe Activator
- Scalatra starter (REST API): https://github.com/scalatra/scalatra-sbt-prototype
- Lift starter (Web framework): https://github.com/lift/lift_25_sbt
- giter8 template (sbt project scaffolding): https://github.com/ymasory/sbt.g8
- CodeBrew: Scala in the browser
- Scala School and related discussion
- About the SBT bash script used in this project: https://github.com/paulp/sbt-extras
- Discussion about "why Scala?": http://news.ycombinator.com/item?id=4980982
Includes links to free Scala books, articles, videos etc. - Scala for the Impatient book and PDF download
- An Introduction to Scala for Java Developers article
- Akka Scalable real-time transaction processing
- Reactive Scala
- Dropwizard-scala for building production-ready RESTful web services
- Even more: LiftWeb's Resources Wiki