File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 22#include < iostream>
33#include < cstring>
44#include < string>
5- #include < windows.h>
5+
6+ #ifdef _WIN32
7+ #include < windows.h>
8+ #endif
69
710#include " Plugin.hpp"
811
1114#endif
1215#define LUA_DEFINE (name ) Define(#name, [](lua_State *L) -> int
1316
14- typedef UINT (CALLBACK* JVMDLLFunction)(JavaVM**, void **, JavaVMInitArgs*);
17+ #ifdef _WIN32
18+ typedef UINT (CALLBACK* JVMDLLFunction)(JavaVM**, void **, JavaVMInitArgs*);
19+ #endif
1520
1621int Plugin::CreateJava (std::string classPath)
1722{
@@ -21,7 +26,15 @@ int Plugin::CreateJava(std::string classPath)
2126 }
2227
2328 #ifdef _WIN32
24- HINSTANCE jvmDLL = LoadLibrary (" .\\ jre\\ bin\\ server\\ jvm.dll" );
29+ char inputPathDll[] = " %JAVA_HOME%\\ jre\\ bin\\ server\\ jvm.dll" ;
30+ TCHAR outputPathDll[32000 ];
31+ DWORD result = ExpandEnvironmentStrings ((LPCTSTR)inputPathDll, outputPathDll, sizeof (outputPathDll) / sizeof (*outputPathDll));
32+ if (!result) {
33+ Onset::Plugin::Get ()->Log (" Failed to find JDK/JRE jvm.dll, please ensure Java 8 is installed. Exiting..." );
34+ return 1 ;
35+ }
36+
37+ HINSTANCE jvmDLL = LoadLibrary (outputPathDll);
2538 if (!jvmDLL) {
2639 Onset::Plugin::Get ()->Log (" Failed to find JDK/JRE jvm.dll, please ensure Java 8 is installed. Exiting..." );
2740 return 1 ;
You can’t perform that action at this time.
0 commit comments