How to pass :jvm-opts to clj from terminal?

This is how i use to call clojurescript from terminal:

clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version \"1.9.946\"}}} '  -m cljs.repl.node

after upgrading Java it is required to pass jvm options “–add-modules java.xml.bind” to the command line.
I am not sure how do i pass these options, i tried variations of the following:

clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version \"1.9.946\"}}} ' -O:jvm-opts:add-modules:java.xml.bind -m cljs.repl.node
clj -Sdeps '{:jvm-opts ["--add-modules" "java.xml.bind"] :deps {org.clojure/clojurescript {:mvn/version "1.9.946"}}} '  -m cljs.repl.node

I think you can also pass JVM opts directly via -J but I’m not entirely sure how to format that. -O is used for activating an alias an using its :jvm-opts.

You could just upgrade to 1.10.238 which fixes the Java9 issues.

The -O flag is used to pass alias names, not options. So one choice is to create an alias:

:aliases {:xb {:jvm-opts ["–add-modules java.xml.bind"]}}

then activate the alias at the command line:

clj -O:xb ...etc...

Or you can supply jvm options directly in the command line with -J:

clj -J–add-modules java.xml.bind ...etc...


Thanks @alexmiller , @seancorfield answered on clojurian that the syntax for -J flag is

clj -J--add-modules -Jjava.xml.bind

1 Like

Oh thank you, I copy/pasted the option and did not even notice it contained a space. The alias definition should then be this as well:

:aliases {:xb {:jvm-opts ["–add-modules" "java.xml.bind"]}}


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.