void findSuitableJava()

in src/main/cpp/launcher/windows/src/Launcher.c [330:384]


void findSuitableJava(LauncherProperties * props) {
    if(!isOK(props)) return;
    
    //resolve testJVM file
    resolveTestJVM(props);
    
    if(!fileExists(props->testJVMFile->resolved)) {
        writeMessageA(props, OUTPUT_LEVEL_NORMAL, 1, "Can`t find TestJVM classpath : ", 0);
        writeMessageW(props, OUTPUT_LEVEL_NORMAL, 1, props->testJVMFile->resolved, 1);
        showErrorW(props, JVM_NOT_FOUND_PROP, 1, javaArg);
        props->status = ERROR_JVM_NOT_FOUND;
        return;
    } else if(!isTerminated(props)) {
        
        // try to get java location from command line arguments
        writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "", 1);
        writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Finding JAVA...", 1);
        
        //WCHAR * java = NULL;
        
        if(props->userDefinedJavaHome!=NULL) { // using user-defined JVM via command-line parameter
            writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "[CMD Argument] Try to use java from ", 0);
            writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, props->userDefinedJavaHome, 1);
            
            trySetCompatibleJava(props->userDefinedJavaHome, props);
            if( props->status == ERROR_JVM_NOT_FOUND || props->status == ERROR_JVM_UNCOMPATIBLE) {
                const char * prop = (props->status == ERROR_JVM_NOT_FOUND) ?
                    JVM_USER_DEFINED_ERROR_PROP :
                    JVM_UNSUPPORTED_VERSION_PROP;
                    showErrorW(props, prop, 1, props->userDefinedJavaHome);
            }
        } else { // no user-specified java argument
            findSystemJava(props);
            if( props->java ==NULL) {
                writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "... no java was found", 1);
                if(props->status == ERROR_BUNDLED_JVM_EXTRACTION) {
                    showErrorW(props, BUNDLED_JVM_EXTRACT_ERROR_PROP, 1, javaArg);
                } else if(props->status == ERROR_BUNDLED_JVM_VERIFICATION) {
                    showErrorW(props, BUNDLED_JVM_VERIFY_ERROR_PROP, 1, javaArg);
                } else {
                    showErrorW(props, JVM_NOT_FOUND_PROP, 1, javaArg);
                    props->status = ERROR_JVM_NOT_FOUND;
                }                
            }
        }
        
        if(props->java!=NULL) {
            writeMessageA(props, OUTPUT_LEVEL_NORMAL, 1, "Compatible jvm was found on the system", 1);
            printJavaProperties(props, props->java);
        } else {
            writeMessageA(props, OUTPUT_LEVEL_NORMAL, 1, "No compatible jvm was found on the system", 1);
        }
    }
    return;
}