コード例 #1
0
bool JavaMachineManager::run()
{
  string vmorder = m_resman.getProperty(ResourceManager::KEY_JVMSEARCH);

  if (m_localVMenabled)
    {
      if (internalRun(m_localVM, "bundled"))
	{
	  return true;
	}

//       DEBUG("Trying to use bundled VM " + m_localVM.JavaHome);        
//       if (m_localVM.runProc(m_resman, m_useConsole, "bundled"))
// 	{
// 	  m_exitCode = m_localVM.getExitCode();
// 	  return true;
// 	}
//       if (m_localVM.run(m_resman, "bundled"))
// 	return true;
    }

  if (vmorder == "")
    {
      vmorder = "registry;jdkpath;jrepath;javahome;jview;exepath";
    }
    
  DEBUG("JSmooth will now try to use the VM in the following order: " + vmorder);
    
  vector<string> jvmorder = StringUtils::split(vmorder, ";,", "");

  Version max(m_resman.getProperty(ResourceManager:: KEY_MAXVERSION));
  Version min(m_resman.getProperty(ResourceManager:: KEY_MINVERSION));

  for (vector<string>::const_iterator i = jvmorder.begin(); i != jvmorder.end(); i++)
    {
      DEBUG("------------------------------");

      if (*i == "registry")
        {
	  DEBUG("Trying to use a JVM defined in the registry (" + StringUtils::toString(m_registryVms.size()) + " available)");
	  string vms = "VM will be tried in the following order: ";
	  for (int i=0; i<m_registryVms.size(); i++)
	    {
	      vms += m_registryVms[i].VmVersion.toString();
	      vms += ";";
	    }
	  DEBUG(vms);

	  for (int i=0; i<m_registryVms.size(); i++)
            {
	      DEBUG("- Trying registry: " + m_registryVms[i].toString());

	      if (internalRun(m_registryVms[i], "registry") == true)
		return true;

	      DEBUG("Couldn't use this VM, now trying something else");
            }
        } 
      else if ((*i == "jview") && m_acceptExe)
	{
	  DEBUG("- Trying to launch the application with JVIEW");
	  if (m_jviewVm.runProc(m_resman, ! m_useConsole))
	    {
	      return true;
	    }

	} 
      else if ((*i == "javahome") && (m_javahomeVm.size()>0))
	{
	  DEBUG("- Trying to use JAVAHOME");
	  if (internalRun(m_javahomeVm[0], "jrehome"))
	    return true;
	} 
      else if ((*i == "jrepath") && (m_jrepathVm.size()>0))
	{
	  DEBUG("- Trying to use JRE_HOME");
	  if (internalRun(m_jrepathVm[0], "jrehome"))
	    return true;
	} 
      else if (*i == "exepath")
	{
	  DEBUG("- Trying to use PATH");

	  SunJVMLauncher launcher;
	  if (launcher.runProc(m_resman, m_useConsole, "path"))
	    {
	      m_exitCode = m_localVM.getExitCode();
	      return true;
	    }
	}
    }

  DEBUG("Couldn't run any suitable JVM!");
  return false;
}
コード例 #2
0
ファイル: JavaMachineManager.cpp プロジェクト: Mikioo/jn
bool JavaMachineManager::run()
{
  string vmorder = EXE_MAKER_SEARCH_JRE_ORDER;
    
  DEBUG("JSmooth will now try to use the VM in the following order: " + vmorder);
    
  vector<string> jvmorder = StringUtils::split(vmorder, ";,", "");

  Version max = EXE_MAKER_JAVA_MAX_VERSION;
  Version min = EXE_MAKER_JAVA_MIN_VERSION;

  for (vector<string>::const_iterator i = jvmorder.begin(); i != jvmorder.end(); i++)
  {
      DEBUG("------------------------------");

	  if(*i == "selfvar" && _selfVarVm.size() > 0)
	  {
		  DEBUG("- Trying to use self variable");
		  if (internalRun(_selfVarVm[0], "selfvar"))
			  return true;
	  }
	  else if(*i == "bundled")
	  {
		  DEBUG("- Trying to use bundled jre");
		  if (internalRun(m_localVM, "bundled"))
			  return true;
	  }
	  else if (*i == "registry")
	  {
		DEBUG("Trying to use a JVM defined in the registry (" + StringUtils::toString(m_registryVms.size()) + " available)");
		string vms = "VM will be tried in the following order: ";
		for (int i=0; i<m_registryVms.size(); i++)
	    {
	      vms += m_registryVms[i].VmVersion.toString();
	      vms += ";";
	    }
		DEBUG(vms);

		for (int i=0; i<m_registryVms.size(); i++)
        {
	      DEBUG("- Trying registry: " + m_registryVms[i].toString());

	      if (internalRun(m_registryVms[i], "registry") == true)
			return true;

	      DEBUG("Couldn't use this VM, now trying something else");
        }
	  } 
      else if ((*i == "javahome") && (m_javahomeVm.size()>0))
	  {
		  DEBUG("- Trying to use JAVAHOME");
		  if (internalRun(m_javahomeVm[0], "jrehome"))
			  return true;
	  } 
	  else if ((*i == "jrepath") && (m_jrepathVm.size()>0))
	  {
		DEBUG("- Trying to use JRE_HOME");
		if (internalRun(m_jrepathVm[0], "jrehome"))
			return true;
	  } 
	  else if ((*i == "jdkpath") && (m_jdkpathVm.size()>0))
	  {
		DEBUG("- Trying to use JDK_HOME");
		if (internalRun(m_jdkpathVm[0], "jdkpath"))
		  return true;
	  } 
      else if (*i == "exepath")
	  {
		DEBUG("- Trying to use PATH");

		SunJVMLauncher launcher;
		if (launcher.runProc(m_useConsole, "path"))
	    {
	      m_exitCode = m_localVM.getExitCode();
	      return true;
	    }
	}
  }

  DEBUG("Couldn't run any suitable JVM!");
  return false;
}