[libbluray-devel] Fix jvm.dll loading in Windows

hpi1 git at videolan.org
Thu Nov 5 11:23:07 CET 2015


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed Nov  4 14:33:25 2015 +0200| [f782d270002181f33dcd2450c6e218c1c7627bc6] | committer: hpi1

Fix jvm.dll loading in Windows

$JAVA_HOME/bin should be in dll load path.

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=f782d270002181f33dcd2450c6e218c1c7627bc6
---

 src/libbluray/bdj/bdj.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/libbluray/bdj/bdj.c b/src/libbluray/bdj/bdj.c
index 629177f..833734d 100644
--- a/src/libbluray/bdj/bdj.c
+++ b/src/libbluray/bdj/bdj.c
@@ -67,7 +67,7 @@ static void *_load_jvm_win32(const char **p_java_home)
 
     wchar_t buf_loc[4096] = L"SOFTWARE\\JavaSoft\\Java Runtime Environment\\";
     wchar_t buf_vers[128];
-
+    wchar_t java_path[4096] = L"";
     char strbuf[256];
 
     LONG r;
@@ -108,6 +108,9 @@ static void *_load_jvm_win32(const char **p_java_home)
         WideCharToMultiByte(CP_UTF8, 0, buf_loc, -1, java_home, sizeof(java_home), NULL, NULL);
         *p_java_home = java_home;
         BD_DEBUG(DBG_BDJ, "JavaHome: %s\n", java_home);
+
+        wcscat(java_path, buf_loc);
+        wcscat(java_path, L"\\bin");
     }
 
     dSize = sizeof(buf_loc);
@@ -119,7 +122,9 @@ static void *_load_jvm_win32(const char **p_java_home)
         return NULL;
     }
 
+    SetDllDirectoryW(java_path);
     void *result = LoadLibraryW(buf_loc);
+    SetDllDirectoryW(NULL);
 
     WideCharToMultiByte(CP_UTF8, 0, buf_loc, -1, strbuf, sizeof(strbuf), NULL, NULL);
     if (!result) {



More information about the libbluray-devel mailing list