I need some very basic advice on how to define a working -main function in IntelliJ along the lines of:
(ns clojure.examples.hello
(:gen-class))
(defn -main
[greetee]
(println (str "Hello " greetee "!")))
When I create a project, paste the preceding code in a source file, and set the run configuration (with Script path, module, working dev, and “Run script in REPL” selected), I get :java.lang.Exception: Unable to resolve symbol: -main in this context (NO_SOURCE_FILE:1)" whenever I run (-main "Some Greeting"). Any advice would be helpful.
I think that La Clojure’s REPL starts in the
usernamespace (as most — all? — Clojure REPLs do); you’ll have to switch to your project’s namespace with(in-ns 'clojure.examples.hello)or(use 'clojure.examples.hello)to call functions defined there. Better yet,(require '[clojure.examples.hello :as hello])and call them as(hello/-main "IDEA").