How-to Getting-Started with Leiningen and Clojure App Builds on Ubuntu 14.04 Trusty LTS Linux Easy Guide

September 13th, 2014 by thelinuxevangelist

Leiningen Clojure Builds Quick-Start on Ubuntu 14.04 Trusty LTS



The Linux Tutorial Shows You Step-by-Step How-to Getting-Started with Leiningen and Clojure Builds on Ubuntu 14.04 Trusty Tahr LTS i386/amd64 Linux.

Clojure as Prerequisite to be Successfully Run Need an Oracle Java JDK6+ Working Installation Ubuntu Linux.

Leiningen is the easiest way to use Clojure. With a focus on project automation and declarative configuration, it gets out of your way and lets you focus on your code.

Leiningen Clojure Hello-World App Quick-Start on Ubuntu 14.04 Trusty LTS - Linux Penguin Clojure
  1. Open Terminal Window
    (Press “Enter” to Execute Commands)

    Ctr+Alt+t

    Leiningen Clojure Hello-World App Quick-Start on Ubuntu 14.04 Trusty LTS - Open Terminal
  2. How-to Install Leiningen for Clojure on Ubuntu:

    Installing Leiningen on Ubuntu
  3. Finalize Leiningen Setup and Get a Clojure Build Hello-World App:

    mkdir $HOME/Documents/Clojure && cd $HOME/Documents/Clojure
    lein new myapp

    The Command First Finalize Leiningen Installation and then Create a Skeleton of a simple Clojure App…

  4. How-to Install Required Oracle Java JDK on Ubuntu:

    Install Oracle JDK 6/7/8 for Ubuntu
  5. The Core of the App is in the myapp/src/myapp/core.cli File

    Default content:

    (ns myapp.core)
    (defn foo
    "I don't do a whole lot."
    [x]
    (println x "Hello, World!"))
    

    Note that the Namespace declaration Matches the Folder Structure.
    Since the core namespace is inside the myapp folder, its name is myapp.core.

  6. Then Specify a Namespace in the project.cli File to Make a Working App:

    cd myapp
    nano project.cli

    For example, we could Set the foo Function from the myapp.core namespace as the Entry Point for the application Using the :main Key:

    (defproject myapp "0.1.0-SNAPSHOT"
     :description "FIXME: write description"
     :url "http://example.com/FIXME"
     :license {:name "Eclipse Public License"
          :url "http://www.eclipse.org/legal/epl-v10.html"}
     :dependencies [[org.clojure/clojure "1.6.0"]]
     ;;this will set foo as the main function
     :main myapp.core/foo)
    
    

    Ctrl+x to Save & Exit from nano Editor :)

  7. The You can Run the Clojure Hello-World App with the Command:

    lein run Happy

    That will Return as Output:

    Happy Hello, World!

    Troubleshooting Leiningen/Clojure Error loading project.cli:

    Solve error loading project.cli
Share on Tumblr

Tags: , , , , , , , , , , , , , , , , , , ,


Comments are disabled