Ejemplo n.º 1
0
bool LocateJVM()
{
	bool result;
	if (FindJVMInEnvVar(LoadStdString(IDS_JDK_ENV_VAR).c_str(), result))
	{
		return result;
	}


        std::vector<std::string> jrePaths;
        if(need64BitJRE) jrePaths.push_back(GetAdjacentDir("jre64"));
        jrePaths.push_back(GetAdjacentDir("jre"));
        for(std::vector<std::string>::iterator it = jrePaths.begin(); it != jrePaths.end(); ++it) {
          if (FindValidJVM((*it).c_str()) && Is64BitJRE(jvmPath) == need64BitJRE)
          {
                  return true;
          }
        }

	if (FindJVMInRegistry())
	{
		return true;
	}

	if (FindJVMInEnvVar("JAVA_HOME", result))
	{
		return result;
	}

	MessageBoxA(NULL, "No JVM installation found. Please reinstall the product or install a JDK.", "Error Launching IntelliJ Platform", MB_OK);
	return false;
}
bool LocateJVM()
{
    bool result;
    if (FindJVMInEnvVar(LoadStdString(IDS_JDK_ENV_VAR).c_str(), result))
    {
        return result;
    }

    if (FindJVMInSettings()) return true;

    std::vector<std::string> jrePaths;
    if(need64BitJRE) jrePaths.push_back(GetAdjacentDir("jre64"));
    jrePaths.push_back(GetAdjacentDir("jre"));
    for(std::vector<std::string>::iterator it = jrePaths.begin(); it != jrePaths.end(); ++it) {
        if (FindValidJVM((*it).c_str()) && Is64BitJRE(jvmPath) == need64BitJRE)
        {
            return true;
        }
    }

    if (FindJVMInEnvVar("JAVA_HOME", result))
    {
        return result;
    }

    if (FindJVMInRegistry())
    {
        return true;
    }

    std::string jvmError;
    jvmError = "No JVM installation found. Please install a " BITS_STR " JDK.\n"
               "If you already have a JDK installed, define a JAVA_HOME variable in\n"
               "Computer > System Properties > System Settings > Environment Variables.";

    if (IsWow64())
    {
        // If WoW64, this means we are running a 32-bit program on 64-bit Windows. This may explain
        // why we couldn't locate the JVM.
        jvmError += "\n\nNOTE: We have detected that you are running a 64-bit version of the "
                    "Windows operating system but are running the 32-bit executable. This "
                    "can prevent you from finding a 64-bit installation of Java. Consider running "
                    "the 64-bit version instead, if this is the problem you're encountering.";
    }

    std::string error = LoadStdString(IDS_ERROR_LAUNCHING_APP);
    MessageBoxA(NULL, jvmError.c_str(),  error.c_str(), MB_OK);
    return false;
}
std::string CollectLibJars(const std::string& jarList)
{
    std::string libDir = GetAdjacentDir("lib");
    if (libDir.size() == 0 || !FileExists(libDir))
    {
        return "";
    }

    std::string result;
    int pos = 0;
    while (pos < jarList.size())
    {
        int delimiterPos = jarList.find(';', pos);
        if (delimiterPos == std::string::npos)
        {
            delimiterPos = jarList.size();
        }
        if (result.size() > 0)
        {
            result += ";";
        }
        result += libDir;
        result += jarList.substr(pos, delimiterPos - pos);
        pos = delimiterPos + 1;
    }
    return result;
}
Ejemplo n.º 4
0
bool LocateJVM()
{
	bool result;
	if (FindJVMInEnvVar(LoadStdString(IDS_JDK_ENV_VAR).c_str(), result))
	{
		return result;
	}

	std::string jreDir = GetAdjacentDir("jre");
	if (FindValidJVM(jreDir.c_str()) && Is64BitJRE(jvmPath) == need64BitJRE)
	{
		return true;
	}

	if (FindJVMInRegistry())
	{
		return true;
	}

	if (FindJVMInEnvVar("JAVA_HOME", result))
	{
		return result;
	}

	MessageBoxA(NULL, "No JVM installation found. Please reinstall the product or install a JDK.", "Error Launching IntelliJ Platform", MB_OK);
	return false;
}