Skip to content

Commit f91a3c2

Browse files
authored
Better debugging for Windows DLL JNI booting (#740)
1 parent 17563c6 commit f91a3c2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

jnius/jnius_jvm_desktop.pxi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ cdef void create_jnienv() except *:
4545
args.nOptions = len(optarr)
4646
args.ignoreUnrecognized = JNI_FALSE
4747

48+
attempted = []
4849
if sys.version_info >= (3, 8):
4950
# uh, let's see if this works and cleanup later
5051
java = get_java_setup('win32')
@@ -61,15 +62,18 @@ cdef void create_jnienv() except *:
6162
if not os.path.isdir(path):
6263
continue
6364
with os.add_dll_directory(path):
65+
attempted.append(path)
6466
try:
6567
ret = JNI_CreateJavaVM(&jvm, <void **>&_platform_default_env, &args)
6668
except Exception as e:
6769
pass
6870
else:
6971
break
7072
else:
71-
raise Exception("Unable to create jni env, no jvm dll found.")
72-
73+
if len(attempted) > 0:
74+
raise Exception("Unable to create jni env, no jvm dll found in %s" % str(attempted))
75+
else:
76+
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)
7377
else:
7478
ret = JNI_CreateJavaVM(&jvm, <void **>&_platform_default_env, &args)
7579

0 commit comments

Comments
 (0)