public static IVMInstall ensureJavaXXdefaultVM(String version) throws CoreException {
    // Before doing anything check the current default VM
    IVMInstall vm = JavaRuntime.getDefaultVMInstall();
    if (JavaUtils.isJavaXX(vm, version)) {
      return vm; // Done!
    }

    vm = getJavaXXVM(version);
    if (vm == null) {
      vm = JavaUtils.createVM(getVMLocation(version));
    }
    if (!JavaUtils.isJavaXX(vm, version)) {
      throw new Error("vm at " + vm.getInstallLocation() + " doesn't look like a Java " + version);
    }
    JavaRuntime.setDefaultVMInstall(vm, new NullProgressMonitor());
    return vm;
  }
 private static IVMInstall getJavaXXVM(String version) {
   List<IVMInstall> vms = JavaUtils.getAllVMs();
   for (IVMInstall vm : vms) {
     if (JavaUtils.isJavaXX(vm, version)) {
       return vm; // Found one
     }
   }
   // Didn't find one
   return null;
 }