Skip to content

Commit

Permalink
Better debugging for Windows DLL JNI booting (#740)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmacdonald authored Feb 6, 2025
1 parent 17563c6 commit f91a3c2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions jnius/jnius_jvm_desktop.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ cdef void create_jnienv() except *:
args.nOptions = len(optarr)
args.ignoreUnrecognized = JNI_FALSE

attempted = []
if sys.version_info >= (3, 8):
# uh, let's see if this works and cleanup later
java = get_java_setup('win32')
Expand All @@ -61,15 +62,18 @@ cdef void create_jnienv() except *:
if not os.path.isdir(path):
continue
with os.add_dll_directory(path):
attempted.append(path)
try:
ret = JNI_CreateJavaVM(&jvm, <void **>&_platform_default_env, &args)
except Exception as e:
pass
else:
break
else:
raise Exception("Unable to create jni env, no jvm dll found.")

if len(attempted) > 0:
raise Exception("Unable to create jni env, no jvm dll found in %s" % str(attempted))
else:
raise Exception("Unable to create jni env, no valid java library paths were found in %s, perhaps you need to update JAVA_HOME" % jdk_home)
else:
ret = JNI_CreateJavaVM(&jvm, <void **>&_platform_default_env, &args)

Expand Down

0 comments on commit f91a3c2

Please sign in to comment.