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; }
public static IVMInstall createLauncher(ILaunchConfiguration configuration) throws CoreException { IVMInstall launcher = getVMInstall(configuration); if (!launcher.getInstallLocation().exists()) throw new CoreException( LauncherUtils.createErrorStatus( MDEMessages.WorkbenchLauncherConfigurationDelegate_jrePathNotFound)); return launcher; }