clj-python / clj-python/libpython-clj

cljbridge fails to create Java VM

Open
#275 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Clojure
Stars
1.2k
Forks
74
PR merge metrics
No merged PRs in 30d

Description

This:
cljbridge.init_jvm(start_repl=True)

results in:
RuntimeError: Failed to create Java VM. Return code = -1

My context

  • MacOS 15.7.2, Python 3.9.6
  • tested with Java temurin@17 & temurin@21 (via brew install)

Error

At commandline:

% python3 -m venv .venv           
% source .venv/bin/activate
(.venv) % export PATH=/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin:$PATH
(.venv) % export JAVA_HOME=$(/usr/libexec/java_home -v 17)                       
(.venv) % env | egrep 'JAVA|JDK'
JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home

(.venv) % python3               

At Python REPL:

Python 3.9.6 (default, Oct 17 2025, 17:15:53) 
[Clang 17.0.0 (clang-1700.4.4.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from clojurebridge import cljbridge
>>> test_var=10
>>> cljbridge.init_jvm(start_repl=True)
WARNING: Implicit use of clojure.main with options is deprecated, use -M -e (require '[clojure.tools.build.api :as b]'[clojure.string :as str])(let [basis (b/create-basis {:aliases (map keyword [])}) jvm-args (str/join " " (:jvm-opts (:resolve-args basis)))] (println jvm-args))
Unrecognized option: 
Failed to create Java virtual machine.

Traceback (most recent call last):
  File "/Users/foo/projects/myproject/mycodebase/.venv/lib/python3.9/site-packages/javabridge/jutil.py", line 282, in start_thread
    vm.create_mac(args, RQCLS, library_path, libjli_path)
  File "_javabridge.pyx", line 707, in _javabridge.JB_VM.create_mac
RuntimeError: Failed to create Java VM. Return code = -1
Failed to create Java VM
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/foo/projects/myproject/mycodebase/.venv/lib/python3.9/site-packages/clojurebridge/cljbridge.py", line 170, in init_jvm
    javabridge.start_vm(run_headless=True,
  File "/Users/foo/projects/myproject/mycodebase/.venv/lib/python3.9/site-packages/javabridge/jutil.py", line 319, in start_vm
    raise RuntimeError("Failed to start Java VM")
RuntimeError: Failed to start Java VM

cljbridge version: 0.0.8

(.venv) % python3 -m pip install cljbridge
Requirement already satisfied: cljbridge in ./.venv/lib/python3.9/site-packages (0.0.8)

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 by reproducing cljbridge.init_jvm(start_repl=True) with the reported macOS and Java versions, then inspect clojurebridge.cljbridge.init_jvm and its javabridge.start_vm call. Trace the JVM arguments until the empty option causing “Unrecognized option” is identified. Done means the reported Java 17 or 21 setup starts the VM successfully without the error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, macos, python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.