How to Get Started
-
2. Installing Leiningen
How to Install Leiningen for Clojure on Ubuntu
-
3. Making Clojure App
Finalize Leiningen Setup and Get a Clojure Build Hello-World App
First, make the Target Folder:mkdir $HOME/Documents/Clojure && cd $HOME/Documents/Clojure
And then Create it:
lein new myapp
The Command First, Finalize Leiningen Installation and then Create a Skeleton of a simple Clojure App…
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. -
4. Editing Clojure App
Then Specify a Namespace in the project.cli File to Make a Working App
Access the Target:cd myapp
And then Edit it:
(Here for simplicity with the nano Editor, but you can just use Anyone.)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 like:
(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 :)
-
5. Running Clojure App
The you can Run the Clojure Hello-World App
With:lein run Happy
That will Return as Output:
Happy Hello, World!
Troubleshooting Leiningen/Clojure Error loading project.cli
Contents