From 2c2476d547693f1ad30a0e937ae984f5f01e7602 Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Fri, 15 Feb 2019 23:19:04 +0300 Subject: [PATCH] IDEA-207158 IDEA 2019.1 with Java 11: cannot install on Win 10 from scratch The trick with SetCurrentDirectory back and forth doesn't work because the missing dll can be requested asynchrounously (on loading awt.dll). So we can just add the right dir to the dll serach path instead. --- native/WinLauncher/WinLauncher/WinLauncher.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/native/WinLauncher/WinLauncher/WinLauncher.cpp b/native/WinLauncher/WinLauncher/WinLauncher.cpp index 39a7a77281f9..e48eacf942bf 100644 --- a/native/WinLauncher/WinLauncher/WinLauncher.cpp +++ b/native/WinLauncher/WinLauncher/WinLauncher.cpp @@ -581,7 +581,6 @@ bool LoadJVMLibrary() { std::string dllName(jvmPath); std::string binDir = dllName + "\\bin"; - TCHAR currentDir[MAX_PATH]; std::string serverDllName = binDir + "\\server\\jvm.dll"; std::string clientDllName = binDir + "\\client\\jvm.dll"; if ((bServerJVM && FileExists(serverDllName)) || !FileExists(clientDllName)) @@ -593,15 +592,13 @@ bool LoadJVMLibrary() dllName = clientDllName; } - // ensure we can find msvcr100.dll which is located in jre/bin directory; jvm.dll depends on it. - GetCurrentDirectory(sizeof(currentDir),currentDir); - SetCurrentDirectoryA(binDir.c_str()); + // ensure we can find msvcr.dll which is located in jre/bin directory; jvm.dll (awt.dll) depends on it. + SetDllDirectoryA(binDir.c_str()); hJVM = LoadLibraryA(dllName.c_str()); if (hJVM) { pCreateJavaVM = (JNI_createJavaVM) GetProcAddress(hJVM, "JNI_CreateJavaVM"); } - SetCurrentDirectory(currentDir); if (!pCreateJavaVM) { std::string jvmError = "Failed to load JVM DLL ";