practicalli / practicalli/clojure

Java command line options for Clojure CLI

Open
#114 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Makefile
Stars
117
Forks
36
PR merge metrics
No merged PRs in 30d

Description

whats the difference between

-Jopt Pass opt through in java_opts, ex: -J-Xmx512m
-Oalias... Concatenated jvm option aliases, ex: -O:mem

https://clojureverse.org/t/how-to-pass-jvm-opts-to-clj-from-terminal/1940/3?u=drewverlee

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

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...

Supply jvm options directly in the command line with -J: clj -J–add-modules java.xml.bind ...etc...

aliases are a feature of tools.deps, where you can kind of group alternative configurations together and give them a name, and -O lets you apply them

-J is for passing arguments directly to the command that launches the jvm, typically 'java'

What would it look like to psas multiple arguments to the jvm? each one gets a J-

clojure J- J-

it is passing options, flags like -Xmx512m

so for example, you could pass -J-server (which is the default these days)

so for multiple its like clojure ... -J-Xmx512m -j-Xms512

clojure -J-Dfoo=bar -J-Dquux=wibble
Clojure 1.10.1
user=> (System/getProperty "foo")
"bar"
user=> (System/getProperty "quux")
"wibble"
user=> ^D

One -J per argument you want to pass. Beware of white space

some arguments are for scripts, some for jvms, and some for clojure, and some for your code
00:02
clj/clojure also have another of different ways to combine aliases, but -A will usually do want you want

(aliases can also specify jvm options, and -O combines those ignoring the other stuff specified in the aliases)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the clj/clojure command-line entry points and the -J and -O options described in the issue. Compare them with the linked ClojureVerse explanation, including how multiple JVM arguments are passed. Done means the documentation clearly distinguishes direct JVM options from alias-based options and shows the correct repeated-flag syntax.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
cli
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.