Search in sources :

Example 6 with IVMInstall2

use of org.eclipse.jdt.launching.IVMInstall2 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;
    }
}
Also used : IExecutionEnvironment(org.eclipse.jdt.launching.environments.IExecutionEnvironment) IVMInstall(org.eclipse.jdt.launching.IVMInstall) IExecutionEnvironmentsManager(org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager) IVMInstall2(org.eclipse.jdt.launching.IVMInstall2)

Aggregations

IVMInstall (org.eclipse.jdt.launching.IVMInstall)6 IVMInstall2 (org.eclipse.jdt.launching.IVMInstall2)6 IExecutionEnvironment (org.eclipse.jdt.launching.environments.IExecutionEnvironment)3 File (java.io.File)2 IStatus (org.eclipse.core.runtime.IStatus)2 IVMInstallType (org.eclipse.jdt.launching.IVMInstallType)2 IExecutionEnvironmentsManager (org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager)2 IOException (java.io.IOException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 Status (org.eclipse.core.runtime.Status)1 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)1 StandardVMType (org.eclipse.jdt.internal.launching.StandardVMType)1 AbstractVMInstallType (org.eclipse.jdt.launching.AbstractVMInstallType)1 IRuntimeClasspathEntry (org.eclipse.jdt.launching.IRuntimeClasspathEntry)1