There are a few different ways to do development in Clojure.
For example, Leiningen is "the easiest way to use Clojure" (according to their website :)):
It is, in fact, one of the most widely used build and project management tools for Clojure development.
JDK Install
Note that Clojure is a JVM language and JDK is required to use Clojure. For example, refer to this post to install JDK on your machine:
Leiningen Toolchain
Leiningen installation instructions:
For example,
$ wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
$ chmod u+x lein
$ ./lein
First time you run this script, it downloads and installs necessary files.
You can put lein in your PATH
.
For example, if you use BASH on Ubuntu,
~/bin is automatically included.
You can just move the lein script into your bin directory.
Then,
$ lein --version
Leiningen 2.9.8 on Java 17.0.2 OpenJDK 64-Bit Server VM
You can find the basic usage of lein
using lein --help
.
$ lein --help
Leiningen is a tool for working with Clojure projects.
Several tasks are available:
change Rewrite project.clj with f applied to the value at key-or-path.
check Check syntax and warn on reflection.
classpath Write the classpath of the current project to output-file.
clean Removes all files from paths in clean-targets for a project
compile Compile Clojure source into .class files.
deploy Deploy jar and pom to remote repository.
deps Download and examine dependencies.
do Higher-order task to perform other tasks in succession.
help Display a list of tasks or help for a given task or subtask.
install Install jar and pom to the local repository; typically ~/.m2.
jar Package up all the project's files into a jar file.
javac Compile Java source files.
new Generate scaffolding for a new project based on a template.
plugin DEPRECATED. Please use the :user profile instead.
pom Write a pom.xml file to disk for Maven interoperability.
release Perform release tasks.
repl Start a repl session either with the current project or standalone.
retest Run only the test namespaces which failed last time around.
run Run the project's -main function.
search Search Central and Clojars for published artifacts.
show-profiles List all available profiles or display one if given an argument.
test Run the project's tests.
trampoline Run a task without nesting the project's JVM inside Leiningen's.
uberjar Package up the project files and all dependencies into a jar file.
update-in Perform arbitrary transformations on your project map.
upgrade Upgrade Leiningen to specified version or latest stable.
vcs Interact with the version control system.
version Print version for Leiningen and the current JVM.
with-profile Apply the given task with the profile(s) specified.
Run `lein help $TASK` for details.
Global Options:
-o Run a task offline.
-U Run a task after forcing update of snapshots.
-h, --help Print this help or help for a specific task.
-v, --version Print Leiningen's version.
These aliases are available:
downgrade, expands to upgrade
See also: readme, faq, tutorial, news, sample, profiles, deploying, gpg,
mixed-source, templates, and copying.
Clojure CLI Tools
If you want to use the Clojure compiler directly without using other build management tools, then you can find the installation instructions on the Clojure official website:
What's Next
Now that we have a development environment set up, let's try creating a simple program.
- Next Step: Creating the first program in Clojure
C C++ C# Crystal D Dart Erlang F# Go Haskell Java Javascript Julia Kotlin Lua Python Rust Scala Swift Typescript