Search in sources :

Example 16 with IVMInstallType

use of org.eclipse.jdt.launching.IVMInstallType in project liferay-ide by liferay.

the class PortalRuntimeComposite method updateJREs.

protected void updateJREs() {
    PortalRuntime portalRuntime = getPortalRuntime();
    IVMInstall currentVM = null;
    if (portalRuntime != null && portalRuntime.getVMInstall() != null) {
        currentVM = portalRuntime.getVMInstall();
    } else {
        currentVM = JavaRuntime.getDefaultVMInstall();
    }
    int currentJREIndex = -1;
    // get all installed JVMs
    installedJREs = new ArrayList<IVMInstall>();
    IVMInstallType[] vmInstallTypes = JavaRuntime.getVMInstallTypes();
    int size = vmInstallTypes.length;
    for (int i = 0; i < size; i++) {
        IVMInstall[] vmInstalls = vmInstallTypes[i].getVMInstalls();
        int size2 = vmInstalls.length;
        for (int j = 0; j < size2; j++) {
            installedJREs.add(vmInstalls[j]);
        }
    }
    // get names
    size = installedJREs.size();
    jreNames = new String[size + 1];
    jreNames[0] = Msgs.defaultWorkbenchJRE;
    for (int i = 0; i < size; i++) {
        IVMInstall vmInstall = installedJREs.get(i);
        jreNames[i + 1] = vmInstall.getName();
        if (vmInstall.equals(currentVM)) {
            currentJREIndex = i + 1;
        }
    }
    if (jreCombo != null) {
        jreCombo.setItems(jreNames);
        jreCombo.select(currentJREIndex);
    }
}
Also used : PortalRuntime(com.liferay.ide.server.core.portal.PortalRuntime) IVMInstall(org.eclipse.jdt.launching.IVMInstall) IVMInstallType(org.eclipse.jdt.launching.IVMInstallType)

Example 17 with IVMInstallType

use of org.eclipse.jdt.launching.IVMInstallType in project eclipse.jdt.ls by eclipse.

the class JDTLanguageServer method configureVM.

public boolean configureVM() throws CoreException {
    String javaHome = preferenceManager.getPreferences().getJavaHome();
    if (javaHome != null) {
        File jvmHome = new File(javaHome);
        if (jvmHome.isDirectory()) {
            IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall();
            File location = defaultVM.getInstallLocation();
            if (!location.equals(jvmHome)) {
                IVMInstall vm = findVM(jvmHome);
                if (vm == null) {
                    IVMInstallType installType = JavaRuntime.getVMInstallType(StandardVMType.ID_STANDARD_VM_TYPE);
                    long unique = System.currentTimeMillis();
                    while (installType.findVMInstall(String.valueOf(unique)) != null) {
                        unique++;
                    }
                    String vmId = String.valueOf(unique);
                    VMStandin vmStandin = new VMStandin(installType, vmId);
                    String name = StringUtils.defaultIfBlank(jvmHome.getName(), "JRE");
                    vmStandin.setName(name);
                    vmStandin.setInstallLocation(jvmHome);
                    vm = vmStandin.convertToRealVM();
                }
                JavaRuntime.setDefaultVMInstall(vm, new NullProgressMonitor());
                JDTUtils.setCompatibleVMs(vm.getId());
                return true;
            }
        }
    }
    return false;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IVMInstall(org.eclipse.jdt.launching.IVMInstall) IVMInstallType(org.eclipse.jdt.launching.IVMInstallType) File(java.io.File) VMStandin(org.eclipse.jdt.launching.VMStandin)

Example 18 with IVMInstallType

use of org.eclipse.jdt.launching.IVMInstallType in project eclipse.jdt.ls by eclipse.

the class TestVMInstall method setTestJREAsDefault.

public static void setTestJREAsDefault() throws CoreException {
    IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(VMTYPE_ID);
    IVMInstall testVMInstall = vmInstallType.findVMInstall("1.8");
    if (!testVMInstall.equals(JavaRuntime.getDefaultVMInstall())) {
        // set the 1.8 test JRE as the new default JRE
        JavaRuntime.setDefaultVMInstall(testVMInstall, new NullProgressMonitor());
    }
    JDTUtils.setCompatibleVMs(VMTYPE_ID);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IVMInstall(org.eclipse.jdt.launching.IVMInstall) IVMInstallType(org.eclipse.jdt.launching.IVMInstallType)

Example 19 with IVMInstallType

use of org.eclipse.jdt.launching.IVMInstallType in project mdw-designer by CenturyLinkCloud.

the class ProjectConfigurator method getJreContainerClasspathEntry.

private IClasspathEntry getJreContainerClasspathEntry(String desiredVersion) {
    for (IVMInstallType installType : JavaRuntime.getVMInstallTypes()) {
        if (installType instanceof AbstractVMInstallType) {
            AbstractVMInstallType install = (AbstractVMInstallType) installType;
            for (IVMInstall vmInstall : install.getVMInstalls()) {
                if (vmInstall instanceof IVMInstall2) {
                    IVMInstall2 vmInstall2 = (IVMInstall2) vmInstall;
                    if (vmInstall2.getJavaVersion() != null && vmInstall2.getJavaVersion().startsWith(desiredVersion)) {
                        IPath containerPath = new Path(JavaRuntime.JRE_CONTAINER);
                        IPath vmPath = containerPath.append(vmInstall.getVMInstallType().getId()).append(vmInstall.getName());
                        return JavaCore.newContainerEntry(vmPath);
                    }
                }
            }
        }
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IVMInstall(org.eclipse.jdt.launching.IVMInstall) IPath(org.eclipse.core.runtime.IPath) IVMInstallType(org.eclipse.jdt.launching.IVMInstallType) AbstractVMInstallType(org.eclipse.jdt.launching.AbstractVMInstallType) IVMInstall2(org.eclipse.jdt.launching.IVMInstall2)

Aggregations

IVMInstall (org.eclipse.jdt.launching.IVMInstall)19 IVMInstallType (org.eclipse.jdt.launching.IVMInstallType)19 File (java.io.File)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 VMStandin (org.eclipse.jdt.launching.VMStandin)4 ArrayList (java.util.ArrayList)2 IPath (org.eclipse.core.runtime.IPath)2 PortalRuntime (com.liferay.ide.server.core.portal.PortalRuntime)1 IOException (java.io.IOException)1 Path (org.eclipse.core.runtime.Path)1 AbstractVMInstallType (org.eclipse.jdt.launching.AbstractVMInstallType)1 IVMInstall2 (org.eclipse.jdt.launching.IVMInstall2)1 IExecutionEnvironment (org.eclipse.jdt.launching.environments.IExecutionEnvironment)1 IJavaRuntime (org.eclipse.jst.server.core.IJavaRuntime)1 Test (org.junit.Test)1 JvmCoreException (org.talend.designer.runtime.visualization.JvmCoreException)1