This is required to load clojure libraries, use to reffer curent namespaces and
to import java classes. We can use these pre defined source codes in our progrms. These are for commen need in most of programs.
Load a clojure library you can use,
and to print all the loaded namespaces,
If you need to load and reffer all at onec, you can use this command,
And if you only need to reffer to a singl thing you can use
(use '[clojure.some.some :only (thingYouNeed)])
Importing Java libraries and classes
Think if you need to import java IO file in you clojure program you can do it by writing;
If you need to import classes from a java package you can use;
(import [java.util Date Random])
This will import both Date and Random in util package.
Writing clojure programs
We can write a clojure program and store it in a seperate file and we can use it by calling that file. So to do that we can use java namespaces. If the namespace is like com.my-app.util, your clojure file should be placed in file structure
like com/my-app/util.clj. So we must begin the file with namespace as ;
So let's do a test program.
First create a folder called student in the directory where the clojure.jar placed. Then write this coding to a file called name.clj .
(defn my_name [sentence] (str "Welcome " sentence "...!"))
Now run the clojure.jar file and import this clojure file to the interpreter by;(use 'student.name)
Then try this;
It will give the output as;