void searchJavaInstallationFolder()

in src/main/cpp/launcher/windows/src/JavaUtils.c [682:722]


void searchJavaInstallationFolder(LauncherProperties * props) {   
    char executablePath [MAX_PATH];
    GetModuleFileName(0, executablePath, MAX_PATH);
    char * pch = strrchr(executablePath, '\\');    
    char installationFolder [MAX_PATH]= "";
    int i;
    int end = (int) (pch - executablePath);
    printf("%i", end);
    for(i = 0; i < end; i++) {
        installationFolder[i] = executablePath[i];
    }
    strcat(installationFolder, "\\bin\\jre");
    
    // check if JRE is in installation folder
    WCHAR * nestedJreFolder = toWCHAR(installationFolder); 
    if (!fileExists(nestedJreFolder)) {
        // if not exists - return
        return;
    }
    
    // if exists - copy to temp folder to run uninstaller on that jvm
    // to be able to delete jvm in installation folder
    WCHAR * tempJreFolder = NULL;
    tempJreFolder = appendStringW(tempJreFolder, props->testJVMFile->resolved); 
    tempJreFolder = appendStringW(tempJreFolder, L"\\_jvm\\");    
    
    WCHAR * command = NULL;
    appendCommandLineArgument(&command, L"xcopy");
    appendCommandLineArgument(&command, nestedJreFolder);
    appendCommandLineArgument(&command, tempJreFolder);
    appendCommandLineArgument(&command, L"/e");
    appendCommandLineArgument(&command, L"/y");
    
    writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "Copying nested JRE to temp folder", 0);
    
    executeCommand(props, command, NULL, JVM_EXTRACTION_TIMEOUT, props->stdoutHandle, props->stderrHandle, NORMAL_PRIORITY_CLASS);
    
    if (fileExists(tempJreFolder)) {    
        trySetCompatibleJava(tempJreFolder, props);
    }
}