Skip to content

Commit a316cdf

Browse files
committed
Bump, forgot about linux
1 parent e9a287b commit a316cdf

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/Plugin.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
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

@@ -11,7 +14,9 @@
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

1621
int 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;

0 commit comments

Comments
 (0)