Skip to content

Commit 4bf68f4

Browse files
committed
Fix JRUBY-6937 jre JAVA_HOME don't work
1 parent 3be053c commit 4bf68f4

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

jvmlauncher.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,31 +81,33 @@ void JvmLauncher::setJavaCmd(const string cmdPath) {
8181
bool JvmLauncher::checkJava(const char *path, const char *prefix) {
8282
assert(path);
8383
assert(prefix);
84-
logMsg("checkJava(%s)", path);
85-
javaPath = path;
86-
if (*javaPath.rbegin() == '\\') {
87-
javaPath.erase(javaPath.length() - 1, 1);
84+
logMsg("checkJava('%s', '%s')", path, prefix);
85+
86+
std::string tmp(path);
87+
88+
if (*tmp.rbegin() == '\\') {
89+
tmp.erase(tmp.length() - 1, 1);
8890
}
89-
javaExePath = javaPath + prefix + JAVA_EXE_FILE;
90-
javawExePath = javaPath + prefix + JAVAW_EXE_FILE;
91-
javaClientDllPath = javaPath + prefix + JAVA_CLIENT_DLL_FILE;
92-
javaServerDllPath = javaPath + prefix + JAVA_SERVER_DLL_FILE;
91+
javaExePath = tmp + prefix + JAVA_EXE_FILE;
92+
javawExePath = tmp + prefix + JAVAW_EXE_FILE;
93+
javaClientDllPath = tmp + prefix + JAVA_CLIENT_DLL_FILE;
94+
javaServerDllPath = tmp + prefix + JAVA_SERVER_DLL_FILE;
9395
if (!fileExists(javaClientDllPath.c_str())) {
9496
javaClientDllPath = "";
9597
}
9698
if (!fileExists(javaServerDllPath.c_str())) {
9799
javaServerDllPath = "";
98100
}
99-
javaBinPath = javaPath + prefix + JAVA_BIN_DIR;
101+
javaBinPath = tmp + prefix + JAVA_BIN_DIR;
100102
if (fileExists(javaExePath.c_str()) || !javaClientDllPath.empty() || !javaServerDllPath.empty()) {
101103
if (!fileExists(javawExePath.c_str())) {
102104
logMsg("javaw.exe not exists, forcing java.exe");
103105
javawExePath = javaExePath;
104106
}
107+
javaPath = tmp;
105108
return true;
106109
}
107110

108-
javaPath.clear();
109111
javaBinPath.clear();
110112
javaExePath.clear();
111113
javawExePath.clear();

0 commit comments

Comments
 (0)