set LEIN_HOME=c:\dev\leiningen
Next you need to run the Leiningen installer:
lein.bat self-install
If you are behind a firewall you can download the standalone jar file, place it in the 'self-installs' directory. That way you won't need to mess with curl or wget.
The rest of Leiningen uses maven, so this is how you get around an http proxy with maven. Create a setting.xml file in your user's home directory within a folder called .m2.
C:\Users\joe_user\.m2\settings.xml:
<settings>
<proxies>
<proxy>
<id>default</id>
<active>true</active>
<protocol>http</protocol>
<host>PROXY_HOST</host>
<port>PROXY_PORT</port>
<username>YOUR_PROXY_USERNAME</username>
<password>YOUR_PROXY_PASSWORD</password>
<nonProxyHosts>localhost</nonProxyHosts>
</proxy>
</proxies>
</settings>
At this point I'd recommend testing things out from the command line.
Test line.bat to ensure you get the help menu.
Create a new project using lein.bat new.
Pull in dependency's for the project by going into the project directory and running lein.bat deps.
This will test the maven proxy configuration.
Once you have Leiningen setup and installed it's time to setup eclipse. I'm going to refer to the labrepl wiki instructions for setting up Eclipse with counterclockwise. You don't have to go all the way through the instructions since we aren't setting up labrepl, but it wouldn't hurt to install the Git and Maven plugins as well as CounterClockWise, which are all discussed.
Great, now I'm going to refer you to the sexp.posterous blog, which has simple instructions to create the external calls to the Leiningen script from Eclipse. These can then be used by all of your Clojure projects and should only take you about 5 minutes to setup.
Now you have your basic Eclipse-Clojure-Leiningen environment setup and I'll cover general use and some gotchas that I ran into.
The first thing you want to do is create a new Eclipse project. Select the 'Clojure' type for your project. If you don't see this option, then perhaps you didn't get the CounterClockWise plug-in properly installed. It should look like this:
![]() |
New Project Wizard |
We will now run some of the Leiningen external tools you setup earlier. If you have difficulty getting the commands to run, I've found I sometimes have to click on the project name before I run the command, as I'm showing in this pic:
![]() |
External Tools Drop-Down |
Run the Leiningen 'new' command first. This will add some files and folders to the existing Eclipse project. (You may need to refresh the project before they appear.) The files of interest are the project.clj file in the project root and the core.clj files under /src and /test in your project's namespace, which in my case is helloWorld - the same name as the project. It get's this name, based on how we setup the Leiningen 'new' command. You can think of the Clojure namespace being similar to a Java package.
Your setup should now look something like this view from the Eclipse package manager:
![]() |
Package Manager View |
Next you will run the Leiningen 'deps' command from the external tools drop-down. This will look at the project.clj file and download any necessary dependencies and put them into the /lib folder. Leiningen uses Maven to do this, which is why I had to add the settings.xml file to Maven to get through my http proxy. You will not need to do this if you don't have to deal with a proxy.
Now let's add the test folder that was created by the Leiningen 'new' command to the project's source build path in Eclipse:
![]() |
Java Build Path Window |
You'll notice that after running the 'dep' command you have a build error on your project. This is because 'dep' wipes out the /classes folder.
Run the Leiningen 'compile' command and it will be restored. You may need to refresh your project after you run compile.
FYI: Just so you know when you are in the package manage view, if there ever is a folder that you know exists, which you cannot see, it is likely because the folder is configured as a build path library object for your project.
Now let's modify the default code and create a simple hello world program which we want to be able to package and run outside of Eclipse. To do this you will modify the src/core.clj and project.clj files.
Aside from the hello world function, you will also need to add the :gen-class specification to your core.clj file in order to create runnable java class files. Note that we have given the function the name of -main, which is the same as the main method for a Java program.
(ns helloWorld.core (:gen-class)) (defn -main [msg] (println "Hello" msg))
Now on to the project.clj file, which lists dependencies and also needs to point to the main method.
Note the :manifest specification in the project.clj file shown below. The manifest does not need to be specified if you are going to only use the standalone jar using Leiningen's 'uberjar' tool, since clojure is included with standalone jar. If however, you wanted to have several projects deployed somewhere which reference only one instance of the clojure library to save space, you can specify where your libraries live using :manifest.
(defproject helloWorld "1.0.0-SNAPSHOT" :description "FIXME: write description" :dependencies [[org.clojure/clojure "1.3.0"]] :main helloWorld.core :manifest {"Class-Path" "lib/clojure-1.3.0.jar"})
Now run the 'uberjar' command, which will create 2 jar files of your project. One which includes the clojure library, it will have STANDALONE in its name, and another jar which merely references your clojure library, which was specified using :manifest.
You should be able to run your project like so:
c:\UL\workspace-helios32\helloWorld>java -jar helloWorld-1.0.0-SNAPSHOT-standalone.jar Joshua
Hello Joshua
If you don't give this program any parameters it will throw the following "arity" exception. Maybe more about that another time... Enjoy your new environment!
c:\UL\workspace-helios32\helloWorld>java -jar helloWorld-1.0.0-SNAPSHOT-standalone.jar
Exception in thread "main" clojure.lang.ArityException: Wrong number of args (0)
passed to: core$-main
at clojure.lang.AFn.throwArity(AFn.java:437)
at clojure.lang.AFn.invoke(AFn.java:35)
at clojure.lang.AFn.applyToHelper(AFn.java:159)
at clojure.lang.AFn.applyTo(AFn.java:151)
at helloWorld.core.main(Unknown Source)
Very helpful! Thanks for writing it up!
ReplyDeleteGreat Article
DeleteCloud Computing Projects
Networking Projects
Final Year Projects for CSE
JavaScript Training in Chennai
JavaScript Training in Chennai
The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training
Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us.
ReplyDeleteSAP training in Chennai
I have read your blog its very attractive and impressive. I like it your blog.
ReplyDeleteJava Training in Chennai Core Java Training in Chennai Core Java Training in Chennai
Java Online Training Java Training in Chennai Core Java 8 Training in Chennai Core Java 8 Training in Chennai JavaEE Training in Chennai Java EE Training in Chennai
ReplyDeleteGreetings. I know this is somewhat off-topic, but I was wondering if you knew where I could get a captcha plugin for my comment form? I’m using the same blog platform like yours, and I’m having difficulty finding one? Thanks a lot.
Best AWS Training in Chennai | Amazon Web Services Training Institute in Chennai Velachery, Tambaram, OMR
Advanced AWS Training in Bangalore |Best AWS Training Institute in Bangalore BTMLA ,Marathahalli
Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.
ReplyDeletemicrosoft azure training in bangalore
rpa interview questions and answers
automation anywhere interview questions and answers
blueprism interview questions and answers
uipath interview questions and answers
rpa training in bangalore
Nice tutorial. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated tutorials…
ReplyDeleteBest Devops Training in pune
Devops Training in Bangalore
Power bi training in Chennai
I found this informative and interesting blog so i think so its very useful and knowledge able.I would like to thank you for the efforts you have made in writing this article.
ReplyDeletepython Course in Pune
python Course institute in Chennai
python Training institute in Bangalore
ReplyDeleteNice infromation
Selenium Training In Chennai
Selenium course in chennai
Selenium Training
Selenium Training institute In Chennai
Best Selenium Training in chennai
Selenium Training In Chennai
ReplyDeleteRpa Training in Chennai
Rpa Course in Chennai
Rpa training institute in Chennai
Best Rpa Course in Chennai
uipath Training in Chennai
Blue prism training in Chennai
Data Science Training In Chennai
Data Science Course In Chennai
Data Science Training institute In Chennai
Best Data Science Training In Chennai
Python Training In Chennai
ReplyDeletePython course In Chennai
Protractor Training in Chennai
jmeter training in chennai
Loadrunner training in chennai
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeleteaws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore
I am really happy with your blog because your article is very unique and powerful for new reader.
ReplyDeleteaws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore
Thank you for sharing information. Wonderful blog & good post.
ReplyDeleteaws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore
I found Hubwit as a transparent s ite, a social hub which is a conglomerate of Buyers and Sellers who are ready to offer online digital consultancy at decent cost. stop code
ReplyDeleteWow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot.
ReplyDeleteAngular JS Training in Chennai | Certification | Online Training Course | Angular JS Training in Bangalore | Certification | Online Training Course | Angular JS Training in Hyderabad | Certification | Online Training Course | Angular JS Training in Coimbatore | Certification | Online Training Course | Angular JS Training | Certification | Angular JS Online Training Course
One of the top site with unique and knowledgeable information thank you for sharing.
ReplyDeleteData Analytics Course Online 360DigiTMG
Fantastic article with top quality information found very useful thanks for sharing
ReplyDeleteData Science Course in Hyderabad 360DigiTMG
Fantastic blog with excellent information, found very knowledgeable thanks for sharing.
ReplyDeleteEthical Hacking Course in Bangalore
Nice Information Your first-class knowledge of this great job can become a suitable foundation for these people. I did some research on the subject and found that almost everyone will agree with your blog.
ReplyDeleteCyber Security Course in Bangalore
Writing in style and getting good compliments on the article is hard enough, to be honest, but you did it so calmly and with such a great feeling and got the job done. This item is owned with style and I give it a nice compliment. Better!
ReplyDeleteCyber Security Training in Bangalore
Wow, What a Excellent post. I rceally found this to much informatics. It is what i was searching for.I would like to suggest you that please keep sharing such type of info.Thankdata science courses
ReplyDeleteI've read this post and if I could I desire to suggest you some interesting things or suggestions. Perhaps you could write next articles referring to this article. I want to read more things about it!
ReplyDeleteData Science course
Aivivu chuyên vé máy bay, tham khảo
ReplyDeletevé máy bay đi Mỹ bao nhiêu tiền
vé máy bay mỹ về việt nam
vé máy bay rẻ đi đà nẵng
vé máy bay đi đà lạt khứ hồi
vé máy bay đi phú quốc từ hải phòng