Reputation: 879
Exploring Clojure - I am working through Clojure For The Brave And True. I created the hello world (in this case, I'm a little teapot). I can run it from lein repl just as the book suggests.
The author of the book appears to be a big emacs fan. I am comfortable with Intellij Idea, so installed the Cursive plugin. I then:
Now what? I presumed after loading the contents of the editor, I could run it, but have not figured out how. Obviously, this is a very noob question.
The code in my editor follows.
(ns clojure-noob.core
(:gen-class))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "I'm a little teapot!")
)
The repl window is divided into two panes. The upper pain shows it is connected to the local nREPL server. Then, after loading it states:
Loading src/clojure_noob/core.clj... done
In the lower pane, per comments, I tried two variations of run, both of which failed miserable as you can see below (it didn't surprise me the second failed for it was calling out run, not the function).
run -main
CompilerException java.lang.RuntimeException: Unable to resolve symbol: run in this context, compiling:(/tmp/form-init2302589649746976452.clj:1:4481)
=> #object[clojure_noob.core$_main 0x24d21d67 "clojure_noob.core$_main@24d21d67"]
run clojure-noob.core/-main
CompilerException java.lang.RuntimeException: Unable to resolve symbol: run in this context, compiling:(/tmp/form-init2302589649746976452.clj:1:4481)
=> #object[clojure_noob.core$_main 0x24d21d67 "clojure_noob.core$_main@24d21d67"]
ANSWER Thanks to comments from @Carcigenicate, I was able to figure out what to do. The answer is:
This resulted in the following:
(clojure-noob.core/-main)
I'm a little teapot!
=> nil
Told you it was a noob question!
Upvotes: 2
Views: 547
Reputation: 1162
This will be much easier in the next version of Cursive - the EAP will hopefully be out later this week or next week. You'll have the IntelliJ-standard ways of running -main
functions more easily accessible:
Of course, the Clojure Way is to use the REPL as you're discovering, so continuing to explore that way of programming is definitely to be encouraged!
Upvotes: 0