2

How do you build the clojure into linux or mac executable file? I can't seem to find the answer after googling.

I have a program src/project_name/core.clj . I wish to compile and build native executable. Please help

1 Answer 1

2

You usually compile it into a jar file and run that on the JVM.

However if you have the clojure cli tools installed which you can do on mac with brew using brew install clojure, you can execute .clj files that have shebang at the top like this

#! /usr/bin/env clj
(prn "Hello, world")

After running chmod a+x ./helloworld.clj, I can execute this by running ./helloworld.clj

This doesn't compile anything though. If you want it compiled the build a jar. If you are running leiningen you can use lein uberjar to build a jar file. Then start it with java -jar <artifact-name>.jar

Sign up to request clarification or add additional context in comments.

1 Comment

Using graal VM I think it's possible to go from jar files to native code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.