Skip to end of metadata
Go to start of metadata

Pre-requisites

  • Java 6 (for running Eclipse, you can still use Java 5 for your projects)

Install Eclipse

(If you do not have Eclipse installed, or you want to make isolated tests of the Clojure plugin for Eclipse)

  • Grab the Eclipse ZIP file from http://www.eclipse.org/downloads . If you do not know which "package" to get, pick the "Eclipse IDE for Java Developers" one since it ships out of the box with Git support
  • Unzip it somewhere. The executable is eclipse (linux) or eclipse.exe (windows) located in the eclipse/ directory created by the unzip operation
  • The first time Eclipse is run, it will ask you for a location on your disk where eclipse will put its metadata and will create new projects by default.

Install Counterclockwise (the Clojure plugin for Eclipse)

(Counterclockwise, CCW for short, is the Clojure plugin for Eclipse)

You install it via the “software update center”, that is:

  • Menu Help > Install new software…
  • Paste the following Counterclockwise url in the “Work with:” textbox: http://updatesite.ccw-ide.org/stable/ , Hit Enter
  • Select counterclockwise, verify the “Contact all update sites during …” chekbox is checked, click next, accept licence, etc., restart Eclipse
  • Go to menu Window > Reset Perspective ... this will reset the way the views are layout, and also place correctly the views contributed by Counterclockwise (the Namespace Browser view, placed "behind" the code outline view)

Test the install

Create and run a simple Clojure project ("Hello Betty")

  • Open the Java perspective
    • Window > Open Perspective > Java (a perspective is a predefined layout of views, suitable for a particular type of development)
  • Create a Clojure project
    • With Clojure Project Wizard: File > New > Clojure Project, name it myproject
    • The project is created using the "default" Leiningen Template, which creates a Clojure project with a predefined "myproject.core" namespace in src/myproject/core.clj
  • Add a function definition to myproject.core:
    • Open src/myproject/core.clj, add the following at the end: (defn hello [who] (str "Hello " who " !")), save the file
  • Run the project:
    • With file src/myproject/core.clj open, Hit Ctrl+Alt+S (Cmd+Alt+S on MacOS). This sends the whole file's code to the REPL (and also takes care of starting a REPL for the project if none is currently started)
  • Switch to the REPL in the namespace of your file:
    • Hit Ctrl+Alt+N (Cmd+Alt+N on MacOS). Alternatively, just click on the bottom of the REPL inside the "text input area"
  • Call your function (Hit Enter to send the expression if the cursor is at the end, or hit Ctrl+Enter / Cmd+Enter if the cursor is not at the end of the text):

    > 1:1 helloworld=> (hello "Betty") [Ctrl+Enter]
    > "Hello Betty !"
    
Labels:
  1. Oct 14, 2011

    I am totally new with clojure and eclipse. I have done the installation and running helloworld.clj I am getting all these errors. What am I doing wrong ??

    Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol (helloworld.clj:0)
    at clojure.lang.Compiler.eval(Compiler.java:5440)
    at clojure.lang.Compiler.load(Compiler.java:5857)
    at clojure.lang.RT.loadResourceScript(RT.java:340)
    at clojure.lang.RT.loadResourceScript(RT.java:327)
    at clojure.lang.RT.loadResourceScript(RT.java:319)
    at clojure.main$load_script.invoke(main.clj:220)
    at clojure.main$init_opt.invoke(main.clj:226)
    at clojure.main$initialize.invoke(main.clj:254)
    at clojure.main$null_opt.invoke(main.clj:279)
    at clojure.main$main.doInvoke(main.clj:354)
    at clojure.lang.RestFn.invoke(RestFn.java:513)
    at clojure.lang.Var.invoke(Var.java:385)
    at clojure.lang.AFn.applyToHelper(AFn.java:187)
    at clojure.lang.Var.applyTo(Var.java:482)
    at clojure.main.main(main.java:37)
    Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
    at clojure.lang.LazySeq.sval(LazySeq.java:47)
    at clojure.lang.LazySeq.seq(LazySeq.java:56)
    at clojure.lang.RT.seq(RT.java:450)
    at clojure.core$seq.invoke(core.clj:122)
    at clojure.core$assert_valid_fdecl.invoke(core.clj:5711)
    at clojure.core$sigs.invoke(core.clj:201)
    at clojure.core$defn.doInvoke(core.clj:272)
    at clojure.lang.RestFn.invoke(RestFn.java:495)
    at clojure.lang.Var.invoke(Var.java:381)
    at clojure.lang.AFn.applyToHelper(AFn.java:180)
    at clojure.lang.Var.applyTo(Var.java:482)
    at clojure.lang.Compiler.macroexpand1(Compiler.java:5286)
    at clojure.lang.Compiler.macroexpand(Compiler.java:5341)
    at clojure.lang.Compiler.eval(Compiler.java:5409)
    ... 14 more
    Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
    at clojure.lang.LazySeq.sval(LazySeq.java:47)
    at clojure.lang.LazySeq.seq(LazySeq.java:56)
    at clojure.lang.RT.seq(RT.java:450)
    at clojure.core$seq.invoke(core.clj:122)
    at clojure.core$filter$fn__3714.invoke(core.clj:2130)
    at clojure.lang.LazySeq.sval(LazySeq.java:42)
    ... 27 more
    Caused by: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
    at clojure.lang.RT.seqFrom(RT.java:471)
    at clojure.lang.RT.seq(RT.java:452)
    at clojure.lang.RT.first(RT.java:540)
    at clojure.core$first.invoke(core.clj:53)
    at clojure.core$map$fn__3695.invoke(core.clj:2096)
    at clojure.lang.LazySeq.sval(LazySeq.java:42)
    ... 32 more

    1. Oct 15, 2011

      @Jose, the wiki isn't really the place for support issues on CCW. I recommend you join the CCW users mailing list and ask questions there. The exception looks like a syntax error in your helloworld program so post your code on that mailing list and folks will get you up and running!

  2. Oct 17, 2011

    Step 4 under Create and run a simple Clojure project (Hello World) currently reads

    Type code in it to define a function: (defn hello [world] (str "Hello " who " !")) (leave the (ns helloword) call at the beginning of the file), save the file

    but should actually be

    Type code in it to define a function: (defn hello [who] (str "Hello " who " !")) (leave the (ns helloword) call at the beginning of the file), save the file

  3. Oct 17, 2011

    Code is wrong as noted by Lux.

  4. Dec 21, 2011

    The instructions above should be modified to

    Call your function:
    > 1:1 helloworld=> (hello "Betty")   hit ctrl-enter
    > "Hello Betty !"

    Make it clear that people need to type ctrl-enter now instead of just enter. My teammate had an older version and for him just enter works but for me it is ctrl-enter and this wasted some time.

    Found the solution here:
    http://www.coderanch.com/t/559885/clojure/Incubator/Counter-Clockwise-Eclipse-Plugin-REPL

    1. Dec 21, 2011

      Sincere thanks! I was already wasting time on this too.. yesterday even switched to Ubuntu thinking eclipse or REPL in windows was broken, only to hit the same roadblock.

      I run into problems further on though with eclipse 3.5.2,

      The "Import the maven project into Eclipse" steps don't seem to work regardless of how many variations i try
      I get a pretty ambiguous error when i right click on "labrepl" and selecting "Enable clojure mode" the error is:  "Error while trying to toggle clojure language support for project labrepl; Problems encountered while setting project description", haven't yet found a log to really explain the problem. 

       

      1. Apr 05, 2012

        I was able to solve this problem (clojure 1.3, Eclipse 3.7.2) using following steps:

        • Import the labrepl from git as described above.
        • Deleted the labrepl project but without deleting the on-disk content.
        • Use Import -> Maven -> Existing Maven Projects, choose directory with downloaded git repository.

        After these steps Enable/Disable clojure... worked for me.

        1. May 27, 2012

          I still can't get rid of the error described by Paul B. When I re-import an existing project using Maven the the labrepl is imported, but the labrepl/pom.xml file has the following error message: "Can not calculate the build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:pom:2.4.3 . . ." Is there any fix for this?

          Thanks.

  5. Feb 05, 2012

    Very small typo

    This:

      ....(leave the (ns helloword)...

    Should be:

      ....(leave the (ns helloworld)...

    I would fix it myself but I didn't see a way to edit this page.

    1. Feb 05, 2012

      OK, done, thx

  6. Feb 05, 2012

    I also wasted some time until I found the ctrl-enter to get ther REPL working.  

    1. Feb 05, 2012

      Ok, I added instructions for that too, thx.

  7. Mar 27, 2012

    Stale instructions in the labrepl/EGit section:

     

    Menu File > Import … > Git > Git Repository ; Hit Next

    should be

    Menu File > Import … > Git > Projects From Git; Hit Next

     

    and

    Uncheck "Import Existing Projects"

    should be

    Check "Import as General Project"

     

    Import the maven project into Eclipse

    is not needed; the project is imported automatically in the Git "Import as General Project" step.

     

    • Also, for Maven, the user needs to install a JDK and configure it as the JVM for use when running Eclipse. (Maven gives a warning when Maven is used.)
    1. Mar 29, 2012

      Done, thanks for the report!

  8. May 04, 2012

    I just started looking into Clojure and would like to add that "Browse to Localhost:8080" actually means using Localhost:8080 as URL in your browser (ie. Mozilla Firefox). I spent hours searching for something like a clojure command for that until I found an example on another site that explained it.

    1. May 04, 2012

      done

  9. May 13, 2012

    I tried asking in the google group but no one there seems to know/care about it so I`ll try here also: After I started the tutorial once I cannot start it again. It will give me this error after typing (require 'labrepl):

    NoClassDefFoundError Could not initialize class labrepl__init java.lang.Class.forName0 (:-2) 

    I have to delete the project and download it again from git to be able to start the tutorial again. Does Anyone know how to fix it?

  10. Jul 02, 2012

    I was getting this same error:

    NoClassDefFoundError Could not initialize class labrepl__init java.lang.Class.forName0 (:-2) 

    I managed to fix it by updating Maven dependencies (Maven -> Update Dependencies) and then cleaning the project (Project -> Clean).

    I hope it works for you...

    1. Jul 05, 2012

      I've simplified the documentation since now that Counterclockwise supports Leiningen out of the box,

      • the preferred way to create a new project is via the New > Leiningen Project Wizard
      • there's no need to use maven to bootstrap the Labrepl project
  11. Aug 27, 2012

    Should the section re: labrepl remain here?  The last commit on it was ~10 months ago, and it's starting people off with (relatively speaking) fairly old versions of Clojure, compojure, ring, etc.  People in #clojure seem to be stumbling on it after getting ccw working smoothly…

    1. Aug 30, 2012

      When you write "should ... remain here", are you suggesting that it could live somewhere else, or just drop it entirely (would make the getting started page less frightening).

      Maybe we could drop it, and also create a pull request for the README page of the labrepl project with the instructions for Counterclockwise? (and then let the maintainers of labrepl do whatever they want with it?)

      1. Aug 30, 2012

        Dropping it entirely makes sense IMO; it's hardly essential to "Getting started with Counterclockwise".