This Getting Started Guide provides you all need to know to create a simple web application with Lift. First we will take a look at the prerequisites and then we will show you how to create and run a Lift project using different development environments. We won’t cover how to develop the Lift way, because that can be found in the User Guide.
Assuming you have Java 5 or higher installed, you can get a Lift web application running in three simple steps:
To understand more about what’s going on here, read on …
Lift is written in Scala which is a modern programming language for the Java virtual machine. You need Java 5 or higher already installed for developing and running Lift projects.
Lift depends on the Servlet API 2.5, hence you need a suitable Servlet container to run a Lift-based web application, e.g. Jetty 6 or 7 or Tomcat 6. However, if you’re using the Lift Basic template (see below), this comes with an embedded Jetty server, so installing a separate container isn’t necessary to get started.
Depending on which development environment you choose it might (Ant) or might not (Maven, SBT, Gradle) be necessary to download the Scala distribution:
Lift 2.2 – Scala 2.7.7, 2.8.0, 2.8.1
Lift 2.3 – Scala 2.8.0, 2.8.1
Lift 2.4 – Scala 2.8.0, 2.8.1, 2.9.0, 2.9.0-1, 2.9.1
Lift 2.5 – Scala 2.9.1, 2.9.1-1, 2.9.2, 2.10, 2.10.1, 2.10.2
Lift itself is a collection of libraries that you add to your project, so other than downloading the libraries there is no initial ‘installation’ of Lift required. If you’re using a build tool such as SBT, the Lift libraries are downloaded automatically as part of your project’s build process.
Running Your First Lift Web Application.
The easiest way to get your first Lift web application up and running is to download the latest ‘Lift Basic’ template and use SBT to build.This template comprises a navigation bar, user management functionality (Login / Sign Up etc), an index page demonstrating a dynamically generated ‘Hello World’ message and a placeholder for static content. So, it’s an ideal place to start experimenting with your own Lift code.
To get the Lift Basic template, if you’re using Git:
git clone git://github.com/lift/lift_25_sbt.git
or without Git, manually download and extract the zip or tar. Then, to build and run:
./sbt (sbt.bat on windows)
The Lift Basic template comes with a SBT launcher, so there’s no need to install sbt separately. The command ‘sbt container:start’ will download all necessary libraries (Scala, Lift, Jetty, etc), compile the application, and then launch Jetty as an embedded application – there’s no need to install Jetty separately. You can then open http://localhost:8080 in a web browser to see the application running.
For more details on using SBT and other build tools see:
Other Sample Applications
http://demo.liftweb.net contains many working demonstrations of Lift features
- The multi-user Chat App from Simply Lift demonstrates some of the powerful features in Lift. The Chat app is also running on the home page of http://demo.liftweb.net
- There are a number of other working sample applications available for download on Github. To run them (Git must be installed first), execute the following from the command line:
git clone https://github.com/lift/examples.git
./liftsh (Mac OS/Linux), or liftsh.cmd (Windows)
Wait for the SBT prompt and then:
sbt> project lift-example (Choose the sample you want from the list)
Wait for the server to come up and open your browser to localhost:8080