use of org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager in project bndtools by bndtools.
the class AbstractOSGiLaunchDelegate method getVMInstall.
@Override
public IVMInstall getVMInstall(ILaunchConfiguration configuration) throws CoreException {
IExecutionEnvironmentsManager eeMgr = JavaRuntime.getExecutionEnvironmentsManager();
// Look for a matching JVM install from the -runee setting
String runee = run.getRunee();
if (runee != null) {
IExecutionEnvironment ee = eeMgr.getEnvironment(runee);
if (ee != null) {
// Return the default VM for this EE if the user has selected one
IVMInstall defaultVm = ee.getDefaultVM();
if (defaultVm != null)
return defaultVm;
IVMInstall[] compatibleVMs = ee.getCompatibleVMs();
if (compatibleVMs != null && compatibleVMs.length > 0) {
// Return the strictly compatible VM (i.e. perfect match) if there is one
for (IVMInstall vm : compatibleVMs) {
if (ee.isStrictlyCompatible(vm))
return vm;
}
// No strictly compatible VM, just return the last in the list.
return compatibleVMs[compatibleVMs.length - 1];
}
}
throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, StatusCode.NoVMForEE.getCode(), "Could not find JRE installation matching Execution Environment: " + runee, null));
}
// Still nothing? Use the default JVM from the workspace.
// Eclipse tries really hard to force you to set a default VM, but this can still be null if the default has
// been disposed somehow.
IVMInstall defaultVm = JavaRuntime.getDefaultVMInstall();
if (defaultVm != null) {
return defaultVm;
}
// You still here?? The superclass will look into the Java project, if the run file is in one.
try {
return super.getVMInstall(configuration);
} catch (CoreException e) {
// ignore
}
throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, StatusCode.NoVMForEE.getCode(), "Could not select a JRE for launch. No Execution Environment is specified\n(using '-runee'), there is no default JRE in preferences and no relevant\nJava project settings.", null));
}
use of org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager in project eclipse.jdt.ls by eclipse.
the class JVMConfigurator method getExecutionEnvironment.
public static IExecutionEnvironment getExecutionEnvironment(String name) {
IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
IExecutionEnvironment[] environments = manager.getExecutionEnvironments();
for (IExecutionEnvironment environment : environments) {
if (environment.getId().equals(name)) {
return environment;
}
}
return null;
}
use of org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager in project xtext-eclipse by eclipse.
the class JavaProjectSetupUtil method makeJava7Default.
public static void makeJava7Default() {
if (!isJava7Default) {
IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
IExecutionEnvironment[] environments = manager.getExecutionEnvironments();
for (int i = 0; i < environments.length; i++) {
IExecutionEnvironment environment = environments[i];
if (environment.getId().equals("JavaSE-1.6") && environment.getDefaultVM() == null) {
IVMInstall[] compatibleVMs = environment.getCompatibleVMs();
for (IVMInstall ivmInstall : compatibleVMs) {
if (ivmInstall instanceof IVMInstall2) {
IVMInstall2 install2 = (IVMInstall2) ivmInstall;
if (install2.getJavaVersion().startsWith("1.7")) {
environment.setDefaultVM(ivmInstall);
}
}
}
}
}
isJava7Default = true;
}
}
use of org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager in project xtext-eclipse by eclipse.
the class JavaProjectSetupUtil method makeJava7Default.
public static void makeJava7Default() {
if (!isJava7Default) {
IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
IExecutionEnvironment[] environments = manager.getExecutionEnvironments();
for (int i = 0; i < environments.length; i++) {
IExecutionEnvironment environment = environments[i];
if (environment.getId().equals("JavaSE-1.6") && environment.getDefaultVM() == null) {
IVMInstall[] compatibleVMs = environment.getCompatibleVMs();
for (IVMInstall ivmInstall : compatibleVMs) {
if (ivmInstall instanceof IVMInstall2) {
IVMInstall2 install2 = (IVMInstall2) ivmInstall;
if (install2.getJavaVersion().startsWith("1.7")) {
environment.setDefaultVM(ivmInstall);
}
}
}
}
}
isJava7Default = true;
}
}
use of org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager in project xtext-eclipse by eclipse.
the class JREContainerProvider method getDefaultJREContainerPath.
/**
* @since 2.6
*/
public static IPath getDefaultJREContainerPath() {
if (defaultVMInstall() != null) {
IExecutionEnvironmentsManager executionEnvironmentsManager = JavaRuntime.getExecutionEnvironmentsManager();
IExecutionEnvironment[] executionEnvironments = executionEnvironmentsManager.getExecutionEnvironments();
for (IExecutionEnvironment executionEnvironment : executionEnvironments) {
if (executionEnvironment.isStrictlyCompatible(defaultVMInstall())) {
return newJREContainerPath(executionEnvironment);
}
}
}
return newPreferredContainerPath();
}
Aggregations