Skip to content

cljbridge fails to create Java VM #275

@tjg

Description

@tjg

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions