< prev index next >

modules/jdk.packager/src/main/native/javapackager/win/javapackager.cpp

Print this page

        

*** 407,419 **** #endif delete nv; } } } - } - } } RegCloseKey(hKey); } --- 407,417 ----
*** 441,450 **** --- 439,464 ---- else { return false; } } + #define TRAILING_PATHSEPARATOR '\\' + + std::wstring ExtractFilePath(std::wstring Path) { + std::wstring result; + size_t slash = Path.find_last_of(TRAILING_PATHSEPARATOR); + if (slash != std::wstring::npos) + result = Path.substr(0, slash); + return result; + } + + std::wstring GetCurrentExecutableName() { + TCHAR FileName[MAX_PATH]; + GetModuleFileName(NULL, FileName, MAX_PATH); + return FileName; + } + int wmain(int argc, wchar_t* argv[]) { wchar_t buf[MAX_PATH]; GetModuleFileName(NULL, buf, MAX_PATH); std::wstring javafxhome = buf;
*** 464,485 **** javacmd = L""; javahome = L""; } } else { ! javacmd = L""; } if (javacmd.length() <= 0) { JavaVersion * jv2 = GetMaxVersion(HKEY_LOCAL_MACHINE, "SOFTWARE\\JavaSoft\\Java Development Kit"); if (jv2 != NULL) { javacmd = jv2->path; javahome = jv2->home; } ! else javacmd = L"java.exe"; } std::wstring cmd = L"\"" + javacmd + L"\""; if (javahome.length() > 0) { SetEnvironmentVariable(L"JAVA_HOME", javahome.c_str()); } --- 478,501 ---- javacmd = L""; javahome = L""; } } else { ! std::wstring exe = GetCurrentExecutableName(); ! javacmd = ExtractFilePath(exe) + L"\\java.exe"; } if (javacmd.length() <= 0) { JavaVersion * jv2 = GetMaxVersion(HKEY_LOCAL_MACHINE, "SOFTWARE\\JavaSoft\\Java Development Kit"); if (jv2 != NULL) { javacmd = jv2->path; javahome = jv2->home; } ! else { javacmd = L"java.exe"; } + } std::wstring cmd = L"\"" + javacmd + L"\""; if (javahome.length() > 0) { SetEnvironmentVariable(L"JAVA_HOME", javahome.c_str()); }
< prev index next >