示例#1
0
 public static IVMInstall getVMInstall(ILaunchConfiguration configuration) throws CoreException {
   String jre =
       configuration.getAttribute(
           IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, (String) null);
   IVMInstall vm = null;
   if (jre == null) {
     String name = configuration.getAttribute(IPDELauncherConstants.VMINSTALL, (String) null);
     if (name == null) {
       name = getDefaultVMInstallName(configuration);
     }
     vm = getVMInstall(name);
     if (vm == null) {
       throw new CoreException(
           LauncherUtils.createErrorStatus(
               NLS.bind(MDEMessages.WorkbenchLauncherConfigurationDelegate_noJRE, name)));
     }
   } else {
     IPath jrePath = Path.fromPortableString(jre);
     vm = JavaRuntime.getVMInstall(jrePath);
     if (vm == null) {
       String id = JavaRuntime.getExecutionEnvironmentId(jrePath);
       if (id == null) {
         String name = JavaRuntime.getVMInstallName(jrePath);
         throw new CoreException(
             LauncherUtils.createErrorStatus(
                 NLS.bind(MDEMessages.WorkbenchLauncherConfigurationDelegate_noJRE, name)));
       }
       throw new CoreException(
           LauncherUtils.createErrorStatus(NLS.bind(MDEMessages.VMHelper_cannotFindExecEnv, id)));
     }
   }
   return vm;
 }
示例#2
0
  /**
   * Get the default VMInstall name using the available info in the config, using the JavaProject if
   * available.
   *
   * @param configuration Launch configuration to check
   * @return name of the VMInstall
   * @throws CoreException thrown if there's a problem getting the VM name
   */
  public static String getDefaultVMInstallName(ILaunchConfiguration configuration)
      throws CoreException {
    IJavaProject javaProject = JavaRuntime.getJavaProject(configuration);
    IVMInstall vmInstall = null;
    if (javaProject != null) {
      vmInstall = JavaRuntime.getVMInstall(javaProject);
    }

    if (vmInstall != null) {
      return vmInstall.getName();
    }

    return VMUtil.getDefaultVMInstallName();
  }
示例#3
0
 public static IVMInstall getVMInstall(String name) {
   if (name != null) {
     IVMInstall[] installs = VMUtil.getAllVMInstances();
     for (int i = 0; i < installs.length; i++) {
       if (installs[i].getName().equals(name)) return installs[i];
     }
   }
   return JavaRuntime.getDefaultVMInstall();
 }
示例#4
0
 /**
  * Retrieve the RuntimeManager instance, creating one if necessary.
  *
  * @return RuntimeManager instance.
  */
 public static synchronized RuntimeManager getRuntimeManager() {
   if (rtManager == null) {
     // Perform lookup to find the RuntimeManager instance.
     rtManager = Lookup.getDefault().lookup(RuntimeManager.class);
     // Load the persisted runtimes.
     RuntimeFactory rf = getRuntimeFactory();
     rtManager.loadRuntimes(rf);
     // Make sure the default runtime exists.
     String base = rf.getDefaultBase();
     JavaRuntime rt = rtManager.findByBase(base);
     if (rt == null || !rt.isValid()) {
       // No matching, valid runtime, create a new one.
       String id = rtManager.generateIdentifier();
       rt = rf.createRuntime(base, id);
       rtManager.add(rt);
     }
   }
   return rtManager;
 }