-1

My Python code is:

import jpype

jvm_path = "/Library/Java/JavaVirtualMachines/microsoft-11.jdk/Contents/Home/lib/jli/libjli.dylib"

jpype.startJVM(
    jvm_path,
    classpath=['~/org.alloytools.alloy.dist.jar'],
)

I get the following error:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/<username>/research-llm/alloy-bridge/src/__main__.py", line 5, in <module>
    jpype.startJVM(
  File "/Users/<username>/research-llm/alloy-bridge/.env/lib/python3.10/site-packages/jpype/_core.py", line 224, in startJVM
    _jpype.startup(jvmpath, tuple(args),
FileNotFoundError: [Errno 2] JVM DLL not found: /Library/Java/JavaVirtualMachines/microsoft-11.jdk/Contents/Home/lib/jli/libjli.dylib

A few useful diagnostics:

java -version
openjdk version "11.0.12" 2021-07-20
OpenJDK Runtime Environment Microsoft-25199 (build 11.0.12+7)
OpenJDK 64-Bit Server VM Microsoft-25199 (build 11.0.12+7, mixed mode)


javac -version
javac 11.0.12

python --version
Python 3.10.4

pip show jpype1
Name: JPype1 Version: 1.4.1 Summary: A Python to Java bridge. Home-page: https://github.com/jpype-project/jpype Author: Steve Menard Author-email: devilwolf@users.sourceforge.net License: License :: OSI Approved :: Apache Software License Location: /Users/username/projects/alloy-bridge/.env/lib/python3.10/site-packages Requires: packaging Required-by:

sw_vers
ProductName: macOS ProductVersion: 13.2.1 BuildVersion: 22D68

Given the context, can someone point me in a right direction? I tried a lot myself but couldn't get it working yet.

M Z
  • 4,571
  • 2
  • 13
  • 27
Rodrigo Stv
  • 405
  • 3
  • 11
  • Not sure about that particular JVM but with the Oracle JDK 11 libjli.dylib is in a different place - only later releases (Java 17 for example) have it in that location. – greg-449 May 01 '23 at 10:36

1 Answers1

0

It is possible that the issue is due to different architectures. Ensure that your Python and JDK installations use the same architecture.For example for MM1 Apple chip architecture.

aled
  • 21,330
  • 3
  • 27
  • 34