Getting started with Lift Web Framework by creating your First Project

In this blog, I will explain that how can we create a lift web project. There are 2 ways to do this. Here, I will explain both ways step by step .

1. Download and Run Lift :
To install and run Lift, the only prerequisite is to have Java 1.5 or later installed.
Instructions for installing Java can be found here.
Once you have Java, the following instructions will download, build, and start a basic
Lift application.

For Mac and Linux :

    • Visit http://liftweb.net/download and download the most recent Lift 2.6 ZIP file.
    • Unzip the file.
    • Start Terminal or your favourite shell tool.
    • Navigate into the unzipped folder and into the scala_210 subfolder and then into the
    lift_basic folder.
    • Run ./sbt
    • Required libraries will be downloaded automatically.
    • At the SBT prompt (>), type container:start
    • Open your browser and go to http://127.0.0.1:8080/
    • When you’re done, type exit at the SBT prompt to stop your application from
    running.

For Windows :

    • Visit http://liftweb.net/download and locate the link to the most recent ZIP version
    of Lift 2.6 and save this to disk.
    • Extract the contents of the ZIP file.
    • Navigate in Explorer to the extracted folder, and once inside, navigate into sca‐
    la_210 and then lift_basic.
    • Double-click sbt.bat to run the build tool; a Terminal window should open.
    • Required libraries will be downloaded automatically.
    • At the SBT prompt (>), type container:start .
    • You may find Windows Firewall blocking Java from running. If so, opt to “allow
    access.”
    • Start your browser and go to http://127.0.0.1:8080/
    • When you’re done, type exit at the SBT prompt to stop your application from
    running.

2. Create project using SBT :
If you want to create the lift web project without using the ZIP files, then follow the below steps.
First of all, you will need to configure SBT and the Lift project yourself. We need only five small files for creating the project.

a. First, create an SBT plugin file at project/plugins.sbt (all file names are given relative to the project root directory):

This file tells SBT that you will be using the xsbt-web-plugin and chooses the correct
version based upon your version of SBT.

b. Next, create an SBT build file, build.sbt:

Feel free to change the various versions, though be aware that certain versions of Lift
are only built for certain versions of Scala.
Now that you have the basics of an SBT project, you can launch the sbt console. It should
load all the necessary dependencies, including the proper Scala version, and bring you
to a prompt.

c. Next, create the following file at src/main/webapp/WEB-INF/web.xml:

The web.xml file tells web containers, such as Jetty as configured by xsbt-web-plugin ,to pass all requests on to Lift.

d. Next, create a sample index.html file at src/main/webapp/index.html for our Lift app to
load. For example:

e. Finally, set up the basic Lift boot settings by creating a Boot.scala file at src/main/scala/bootstrap/liftweb/Boot.scala. The following contents will be sufficient:

Cheers, now you have a working Lift project!

Tu run the application, follow below command :

To browse the application, open http://localhost:8080

To get the sample code, just clone the project from here

Written by 

Rishi is a Lead Consultant, with experience of more than 7 years. Rishi is product focused developer who loves developing both front-end user interfaces and scalable back-end infrastructure. He is a good team player, quick learner and a humble person. He has good time management skills, aimed to give best results and fully dedicated towards his work & responsibilities. He is able to work as individual and as well as in team. He loves to share his knowledge, therefore he often writes technical blogs.

1 thought on “Getting started with Lift Web Framework by creating your First Project

Leave a Reply

%d bloggers like this: