In general, while you can call import, require and gen-class as functions, it is usually a good idea to include them in the namespace declaration: (ns goo.bar (:import (java.util Date)) (:gen-class)). Note that they are keywords in this case.
Ah, I seem to have missed that. Reading the doc there is indeed a space between package and class.
But in the first example below the description:
(import java.util.Date)
Soo… confused.
Thank you.
Edit: The reason I’m doing it explicitly is because I’m just learning the basics. It feel intuitive easier to call import, require, gen-class. Like you mention, It seems the standard way is to use keywords from what I’ve seen at other sources, but I have not quite yet grasped the fundamentals yet (obviously)(like, I thought you only used keywords with maps {}, but here it is in list forms. Anyway. Much to learn.
Ya, this is one of the quirks of Clojure, the require and import clauses have a bit of an inconsistent non-intuitive syntax.
import can take one or more “import symbol” or “import list” where an import symbol is a fully qualified package.class like java.util.Date. Or where an import list is a list like (package class1 class2 class3).
The stand-alone import takes a literal list (you must quote it), while the ns form takes an embedded :import clause without a quote. The error message in the original post was telling you that the import expected a literal list.
One thing I did not realize, is that you have to compile the code first. I’m using emacs/cider, so when I just evaluate my buffer, I will get a ClassNotFound on searchbar.core. Now, If go the repl, call the compile function, change into the my namespace, voila, It works. To be fair, that is in the docs somewhere, just a lot of examples on the interweb where it is simply not mentioned. You kinda get spoiled in the beginning learning clojure, just living in the repl, even if you have a file/buffer, you just send it to the repl. As soon as you go into interop, things change.