Mr. Robot
Mr. Robot

Reputation: 1824

How to set up ClojureScript environment with Cursive and Figwheel?

I am trying to render some HTML in the browser using ClojureScript, but am not very close.

So far I have installed: Clojure, leiningen, Figwheel, IntelliJ, Cursive. I would like to use reagent and re-frame. I have tried Chestnut (this is the closest I have come to seeing rendered html). I am not sure if I need anything else.

What I would like to achieve is to use all of these tools as my environment and start creating a web app.

Figwheel seems to be the main problem.

Where I've currently got to: Created a Clojure project with IntelliJ and Cursive. I am following this article to try and get up and running - I've got to the point where it says Start Figwheel from the terminal (lein figwheel). When I do, the terminal in IntelliJ prints

Exception in thread "main" java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter, compiling:(cljs/closure.clj:1:1).

When I google this error, a the solution is to add this line to the project.clj:

:jvm-opts ["--add-modules" "java.xml.bind"]

Then I run lein figwheel in the terminal again and this time I get:

java.lang.module.FindException: Module java.xml.bind not found

Then I got to IntelliJ > File > Project Structure > Platform SDKs and change the SDK path to 1.8. I have tried 12 and 8. Nothing works.

Am I close? How can I move on? I've done the getting started tutorials but they just focus on REPLs and not a full on web development environment etc.

Upvotes: 1

Views: 1471

Answers (2)

Thomas Heller
Thomas Heller

Reputation: 4356

The problem is caused by you using a newer JDK Version (9+) and the older figwheel stuff still expecting JDK8.

One fix is the --add-modules you already found but I'm pretty sure the package name is javax.xml.bind but I might be wrong.

The other fix that is "easier" is just adding an additional dependency to the :dependencies vector.

[javax.xml.bind/jaxb-api "2.3.0"]

Upvotes: 2

Alan Thompson
Alan Thompson

Reputation: 29958

The best way to use Figwheel for the past year is not with Leiningen, but with the Clojure deps.edn system.

Full details are on the Figwheel-Main website: https://figwheel.org/

Work through the tutorial.


For using Cursive, I first create the project directory & files, and then add it to Cursive/IntelliJ via:

 File -> New -> Project from Existing Sources

For a Clojure 'lein' based project, I click on the file project.clj. For a ClojureScript 'deps' based project, you could click on deps.edn, or just the parent directory (I haven't experimented creating CLJS projects).

Upvotes: 0

Related Questions