Search in sources :

Example 6 with IVMInstallType

use of org.eclipse.jdt.launching.IVMInstallType in project webtools.servertools by eclipse.

the class GenericRuntimeComposite method updateJREs.

protected void updateJREs() {
    // get all installed JVMs
    installedJREs = new ArrayList<IVMInstall>();
    IVMInstallType[] vmInstallTypes = JavaRuntime.getVMInstallTypes();
    for (IVMInstallType vit : vmInstallTypes) {
        IVMInstall[] vmInstalls = vit.getVMInstalls();
        for (IVMInstall vmInstall : vmInstalls) installedJREs.add(vmInstall);
    }
    // get names
    int size = installedJREs.size();
    jreNames = new String[size + 1];
    jreNames[0] = Messages.runtimeTypeDefaultJRE;
    for (int i = 0; i < size; i++) {
        IVMInstall vmInstall = installedJREs.get(i);
        jreNames[i + 1] = vmInstall.getName();
    }
}
Also used : IVMInstall(org.eclipse.jdt.launching.IVMInstall) IVMInstallType(org.eclipse.jdt.launching.IVMInstallType)

Example 7 with IVMInstallType

use of org.eclipse.jdt.launching.IVMInstallType in project webtools.servertools by eclipse.

the class JRESelectDecorator method updateJREs.

protected void updateJREs() {
    installedJREs = new ArrayList();
    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]);
        }
    }
    size = installedJREs.size();
    jreNames = new String[size + 1];
    jreNames[0] = GenericServerUIMessages.defaultJRE;
    for (int i = 0; i < size; i++) {
        IVMInstall vmInstall = (IVMInstall) installedJREs.get(i);
        jreNames[i + 1] = vmInstall.getName();
    }
}
Also used : IVMInstall(org.eclipse.jdt.launching.IVMInstall) ArrayList(java.util.ArrayList) IVMInstallType(org.eclipse.jdt.launching.IVMInstallType)

Example 8 with IVMInstallType

use of org.eclipse.jdt.launching.IVMInstallType in project tdi-studio-se by Talend.

the class Tools method searchJdkRootDirectory.

/**
     * Searches the JDK root directory.
     * 
     * @return The JDK root directory, or empty string if not found
     */
private String searchJdkRootDirectory() {
    // search from the JREs that are specified on preference page
    for (IVMInstallType type : JavaRuntime.getVMInstallTypes()) {
        for (IVMInstall install : type.getVMInstalls()) {
            String jdkRootDirectory = install.getInstallLocation().getPath();
            if (null == validateJdkRootDirectory(jdkRootDirectory)) {
                Activator.log(IStatus.INFO, NLS.bind(Messages.jdkRootDirectoryFoundMsg, jdkRootDirectory), new Exception());
                return jdkRootDirectory;
            }
        }
    }
    // search at the same directory as current JRE
    String javaHome = System.getProperty(JAVA_HOME_PROPERTY_KEY);
    for (File directory : getPossibleJdkRootDirectory(javaHome)) {
        String path = directory.getPath();
        if (null == validateJdkRootDirectory(path)) {
            Activator.log(IStatus.INFO, NLS.bind(Messages.jdkRootDirectoryFoundMsg, path), new Exception());
            return path;
        }
    }
    Activator.log(IStatus.WARNING, Messages.jdkRootDirectoryNotFoundMsg, new Exception());
    //$NON-NLS-1$
    return "";
}
Also used : IVMInstall(org.eclipse.jdt.launching.IVMInstall) IVMInstallType(org.eclipse.jdt.launching.IVMInstallType) File(java.io.File) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 9 with IVMInstallType

use of org.eclipse.jdt.launching.IVMInstallType in project sling by apache.

the class DefaultJavaVMInstall method before.

@Override
protected void before() throws Throwable {
    if (JavaRuntime.getDefaultVMInstall() != null) {
        return;
    }
    String jreHome = System.getProperty("java.home");
    File installLocation = new File(jreHome);
    final IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(StandardVMType.ID_STANDARD_VM_TYPE);
    // find an unused VM id
    String id = null;
    do {
        id = String.valueOf(System.currentTimeMillis());
    } while (vmInstallType.findVMInstall(id) != null);
    VMStandin newVm = new VMStandin(vmInstallType, id);
    newVm.setName("Default-VM");
    newVm.setInstallLocation(installLocation);
    IVMInstall realVm = newVm.convertToRealVM();
    JavaRuntime.setDefaultVMInstall(realVm, new NullProgressMonitor());
    // wait for the default vm reconfiguration to settle
    // TODO - find something to poll agains rather than sleeping blindly
    Thread.sleep(5000);
}
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 10 with IVMInstallType

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

the class JREContainerProvider method getConfiguredBREEs.

/**
 * @return an {@link Iterable} of BREE that have a configured default VM<br>
 *         or have a strictly compatible installed JRE (aka "perfect match")
 * @since 2.9
 */
public static Iterable<String> getConfiguredBREEs() {
    final Set<IVMInstall> vms = Sets.newHashSet();
    for (IVMInstallType vmType : JavaRuntime.getVMInstallTypes()) {
        vms.addAll(Arrays.asList(vmType.getVMInstalls()));
    }
    Iterable<IExecutionEnvironment> supportedEEs = filter(Arrays.asList(JavaRuntime.getExecutionEnvironmentsManager().getExecutionEnvironments()), new Predicate<IExecutionEnvironment>() {

        @Override
        public boolean apply(final IExecutionEnvironment ee) {
            return ee.getDefaultVM() != null || any(vms, new Predicate<IVMInstall>() {

                @Override
                public boolean apply(IVMInstall vm) {
                    return ee.isStrictlyCompatible(vm);
                }
            });
        }
    });
    return transform(supportedEEs, new Function<IExecutionEnvironment, String>() {

        @Override
        public String apply(IExecutionEnvironment input) {
            return input.getId();
        }
    });
}
Also used : IExecutionEnvironment(org.eclipse.jdt.launching.environments.IExecutionEnvironment) IVMInstall(org.eclipse.jdt.launching.IVMInstall) IVMInstallType(org.eclipse.jdt.launching.IVMInstallType)

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