10 Şubat 2012 Cuma

Running Joy of Clojure gui code with Cljr environment

I am Clojure beginner and I' ve begun studying the book The Joy of Clojure. It is very good book. As the authors mentioned, it is not for beginners. So, beginners like me experiencing some difficulties in running example source codes. Yesterday, I' ve spent many hours to install Cljr environment (developed by David Edgar Liebke) and to run joy.gui.DynaFrame and joy.gui.socks example. Here' s my solution:
  • Install Cljr:
    1. Download cljr-installer.jar from http://joyofclojure.com/cljr or here.
    2. CD into the directory you' ve downloaded.
    3. java -jar cljr-installer.jar
    4. Add $HOME/.cljr/bin to your PATH. (NOTE: Installer puts the Cljr into $HOME/.cljr). I disliked having Cljr in my Windows home directory. Also blanks in home directory (i.e. "Documents and Settings") made problem in cljr.bat in the /bin folder. So, after running the DynaFrame example, I moved Cljr environment to my favourite folder. I will explain how I do in another blog entry
    5. Download book source code from https://github.com/joyofclojure/book-source/zipball/master.
    6. Unzip source zipball into your favourite folder. There would be 3 folders in your favourite folder.
       |--<your-joy-folder>
          |-- lib
          |-- src
          |-- test

    7. Create new folder classes near those 3 folder.
       |--<your-joy-folder>
          |-- classes
          |-- lib
          |-- src
          |-- test

    8. Add folders src and classes to Cljr classpath
      In cmd command prompt:
         cljr add-classpath src <ENTER>
         cljr add-classpath classes <ENTER>
      You can display the classpath by using cljr list-classpath

    9. Setup is now complete !!!

  • When you want to run examples
    1. In cmd command prompt:
         cd <your-joy-folder> <ENTER> (i.e. cd into sources root, not /src!)
         cljr <ENTER>

    2. Run the examples in Cljr REPL.
      If you want to run gui example:
         user=> (use 'joy.gui.socks)
         nil
         user=> (example-gui)
         nil