ClojureInstallationHello WorldGUI Hello WorldGUI hello world fxmlShadow CLJS (Browser target) Hello WorldFulcro hello worldQuick start
https://clojure.org/guides/getting_started
Create a new file as ~/code/hello-world/core.clj
Inside that file create the following:
x(ns core)
(defn -main []
(println "Hello world!"))
Then create a new file ~/code/hello-world/deps.edn
With:
xxxxxxxxxx
{:deps {}
:paths ["."]}
Then return your current directory to ~/code/hello-world
then run
xxxxxxxxxx
clj -m core
You should get the following as your result:
xxxxxxxxxx
> Hello world!
Create ~/code/$project-name/deps.edn
and add the following to it:
xxxxxxxxxx
{
:deps {
seesaw {:mvn/version "1.5.0"}}}
Go back to ~/code/$project-name/src/$project-name/core.clj
and change it to:
xxxxxxxxxx
(ns $project-name.core
(:use seesaw.core))
(defn -main []
(invoke-later
(-> (frame :title "Hello",
:content "Hello world!",
:on-close :exit)
pack!
show!)))
Then return your current directory to ~/code/$project-name
then run
xxxxxxxxxx
clojure -m $project-name.core
After a short wait you should see a window open with the contents "Hello world!" inside
Associated documentation: Frame documentation
Open the hello-world-fxml
project
Create a new project name, this will be a ClojureScript project as $project-name
Inside ~/code
run npx create-cljs-project $project-name
Create a new file at ~/code/$project-name/src/main/$project_name/core.cljs
add the following:
xxxxxxxxxx
(ns $project-name.core)
(defn -main []
(println "Hello world"))
Open ~/code/$project-name/shadow-cljs.edn
add this to the :builds
keyword
xxxxxxxxxx
{...
:builds
{:frontend
{:target :browser
:modules {:main {:init-fn $project-name.core/-main}}
:devtools
{:http-root "public"
:http-port 8080}
}}}
Create ~/code/$project-name/public/index.html
with
xxxxxxxxxx
<html>
<head>
<meta charset="utf-8" />
<title>Hello World!</title>
</head>
<body>
<script src="/js/main.js"></script>
</body>
</html>
Run npx shadow-cljs watch frontend
in ~/code/$project-name
to expose a development web server, if you still have the watch command running from ealier you should now be able to visit localhost:8080 to see:
Associated documentation: ShadowCLJS Github
git clone https://github.com/fulcrologic/fulcro-template.git
Then run npm install
in the newly created fulcro-template sub directory
To start a build run npm run client/main
or visit http://localhost:9630 & run the build
To start the server run clojure -A:dev
Navigate to http://localhost:3000