Java Code Examples for org.eclipse.jdt.launching.JavaRuntime#getVMInstallTypes()

The following examples show how to use org.eclipse.jdt.launching.JavaRuntime#getVMInstallTypes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JREContainerProvider.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @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();
		}
	});
}
 
Example 2
Source File: ReorgCorrectionsSubProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private IVMInstall findRequiredOrGreaterVMInstall() {
	String bestMatchingCompliance= null;
	IVMInstall bestMatchingVMInstall= null;
	IVMInstallType[] installTypes= JavaRuntime.getVMInstallTypes();
	for (int i= 0; i < installTypes.length; i++) {
		IVMInstall[] installs= installTypes[i].getVMInstalls();
		for (int k= 0; k < installs.length; k++) {
			String vmInstallCompliance= getVMInstallCompliance(installs[k]);
			
			if (fRequiredVersion.equals(vmInstallCompliance)) {
				return installs[k]; // perfect match
				
			} else if (JavaModelUtil.isVersionLessThan(vmInstallCompliance, fRequiredVersion)) {
				continue; // no match
				
			} else if (bestMatchingVMInstall != null) {
				if (JavaModelUtil.isVersionLessThan(bestMatchingCompliance, vmInstallCompliance)) {
					continue; // the other one is the least matching
				}
			}
			bestMatchingCompliance= vmInstallCompliance;
			bestMatchingVMInstall= installs[k];
		}
	}
	return null;
}
 
Example 3
Source File: CheckJavaVersionPostStartupContribution.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
 public void execute() {
     final List standins = new ArrayList();
     final IVMInstallType[] types = JavaRuntime.getVMInstallTypes();
     for (int i = 0; i < types.length; i++) {
         final IVMInstallType type = types[i];
         final IVMInstall[] installs = type.getVMInstalls();
         for (int j = 0; j < installs.length; j++) {
             final IVMInstall install = installs[j];
             standins.add(new VMStandin(install));
         }
     }
     if (standins.isEmpty()) {
     	Display.getDefault().syncExec(new Runnable() {
	
	@Override
	public void run() {
		 if (MessageDialog.openQuestion(Display.getDefault().getActiveShell(), Messages.jreNotFoundTitle, Messages.jreNotFoundMessage)) {
                final BonitaPreferenceDialog dialog = new BonitaPreferenceDialog(Display.getDefault().getActiveShell());
                dialog.open();
            }
	}
});
        
     }
 }
 
Example 4
Source File: JVMConfigurator.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public static IVMInstall findVM(File file, String name) {
	IVMInstallType[] types = JavaRuntime.getVMInstallTypes();
	for (IVMInstallType type : types) {
		IVMInstall[] installs = type.getVMInstalls();
		for (IVMInstall install : installs) {
			if (name != null && name.equals(install.getName())) {
				return install;
			}
			if (file != null && file.equals(install.getInstallLocation())) {
				return install;
			}
		}
	}
	return null;
}
 
Example 5
Source File: TypeInfoViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public TypeInfoLabelProvider(ITypeInfoImageProvider extension) {
	fProviderExtension= extension;
	List locations= new ArrayList();
	List labels= new ArrayList();
	IVMInstallType[] installs= JavaRuntime.getVMInstallTypes();
	for (int i= 0; i < installs.length; i++) {
		processVMInstallType(installs[i], locations, labels);
	}
	fInstallLocations= (String[])locations.toArray(new String[locations.size()]);
	fVMNames= (String[])labels.toArray(new String[labels.size()]);
	
}
 
Example 6
Source File: NewJavaProjectWizardPageOne.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private IVMInstall[] getWorkspaceJREs() {
	List<VMStandin> standins = new ArrayList<VMStandin>();
	IVMInstallType[] types = JavaRuntime.getVMInstallTypes();
	for (int i = 0; i < types.length; i++) {
		IVMInstallType type = types[i];
		IVMInstall[] installs = type.getVMInstalls();
		for (int j = 0; j < installs.length; j++) {
			IVMInstall install = installs[j];
			standins.add(new VMStandin(install));
		}
	}
	return standins.toArray(new IVMInstall[standins.size()]);
}
 
Example 7
Source File: FilteredTypesSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public TypeInfoUtil(ITypeInfoImageProvider extension) {
	fProviderExtension= extension;
	List<IPath> locations= new ArrayList<IPath>();
	List<String> labels= new ArrayList<String>();
	IVMInstallType[] installs= JavaRuntime.getVMInstallTypes();
	for (int i= 0; i < installs.length; i++) {
		processVMInstallType(installs[i], locations, labels);
	}
	fInstallLocations= CollectionsUtil.toArray(locations, IPath.class);
	fVMNames= labels.toArray(new String[labels.size()]);

}
 
Example 8
Source File: FilteredTypesSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates new instance of TypeItemsComparator
 */
public TypeItemsComparator() {
	List<String> locations= new ArrayList<String>();
	List<String> labels= new ArrayList<String>();
	IVMInstallType[] installs= JavaRuntime.getVMInstallTypes();
	for (int i= 0; i < installs.length; i++) {
		processVMInstallType(installs[i], locations, labels);
	}
	fInstallLocations= locations.toArray(new String[locations.size()]);
	fVMNames= labels.toArray(new String[labels.size()]);
}
 
Example 9
Source File: MainProjectWizardPage.java    From sarl with Apache License 2.0 5 votes vote down vote up
private IVMInstall[] getWorkspaceJREs() {
	final List<VMStandin> standins = new ArrayList<>();
	final IVMInstallType[] types = JavaRuntime.getVMInstallTypes();
	for (int i = 0; i < types.length; i++) {
		final IVMInstallType type = types[i];
		final IVMInstall[] installs = type.getVMInstalls();
		for (int j = 0; j < installs.length; j++) {
			final IVMInstall install = installs[j];
			standins.add(new VMStandin(install));
		}
	}
	return standins.toArray(new IVMInstall[standins.size()]);
}
 
Example 10
Source File: ReportLauncherUtils.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public static IVMInstall[] getAllVMInstances( )
{
	ArrayList res = new ArrayList( );
	IVMInstallType[] types = JavaRuntime.getVMInstallTypes( );
	for ( int i = 0; i < types.length; i++ )
	{
		IVMInstall[] installs = types[i].getVMInstalls( );
		for ( int k = 0; k < installs.length; k++ )
		{
			res.add( installs[k] );
		}
	}
	return (IVMInstall[]) res.toArray( new IVMInstall[res.size( )] );
}