Installing the Liftweb framework for Scala turned out to be so easy it hardly merits a note-to-self – even less so a blog post. Yet, it took me a while to figure it out. If you are a Scala/Lift novice like me I hope that this quick post helps you get started. Here’s how to setup Lift on Mac, Windows or Linux.
You don’t need to have Scala installed for this to work.
- Install JRE 1.6+.
- Download the Scala Build Tool V 0.7.7 sbt and save it to some directory.
- Create a script/batch file in the same directory to wrap sbt as shown under notes further below.
- Optionally add the script’s directory to your OS’ search path.
- On Linux, don’t forget to assign exec permission to the script.
- Create a project directory for your lift app somewhere and
- Invoke the sbt script from within your project directory. If you didn’t add sbt to your OS’ search path you have to give its absolute or relative path.
- When prompted, answer
yto create a new project.
- Enter a project name such as
- Enter your org name such as
2.8.1as scala version.
- For everything else accept the defaults.
- Wait for dependencies, which include a Scala version for sbt other than 2.8.1, to download. If you need to access the net via a proxy please refer to the notes at the end of this post.
- At the sbt shell type
*lift is org.lifty lifty 1.6.1to install the lifty plugin – wait a little.
lift create project-blank
- Accept defaults except for the lift version where you need to specify 2.3 (and not the default value of 2.3-RC3).
reloadfor sbt to update your project’s config.
updateto fetch dependencies including lift.
jettyto launch the app.
- Visit http://localhost:8080 to see the Liftweb scaffolding app.
Coming from Python and web2py, a Python MVC framework that’s easy to install and get started with, this is comparatively cumbersome but I am interested in Lift’s “view-first” approach and keen to apply Scala to some projects.
java -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=1024m -Xmx2048M -Xss4M -jar `dirname $0`/sbt-launch-0.7.7.jar "$@"
Windows batch file
java -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=1024m -Xmx2048M -Xss4M -jar "%SCRIPT_DIR%sbt-launch-0.7.7.jar" %*
If you get memory related errors try to reduce the Xmx and MaxPermSize parameters.
To use sbt through a proxy add the following parameters. You can omit username and password if your proxy does not require authentication.
To instruct Jetty to listen on a port other than 8080, you can add
override def jettyPort = 8081 to
Finally, to shutdown jetty type
jetty-stop in the sbt shell.
That’s it. Comments and corrections are very welcome.