org.eclipse.jdt.launching.IVMInstallType Java Examples
The following examples show how to use
org.eclipse.jdt.launching.IVMInstallType.
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: CheckJavaVersionPostStartupContribution.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@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 #2
Source File: GradleProjectImporterTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Test public void testJavaHome() throws Exception { Preferences prefs = JavaLanguageServerPlugin.getPreferencesManager().getPreferences(); String javaHomePreference = prefs.getJavaHome(); IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall(); try { IVMInstallType installType = JavaRuntime.getVMInstallType(StandardVMType.ID_STANDARD_VM_TYPE); IVMInstall[] vms = installType.getVMInstalls(); IVMInstall vm = vms[0]; JavaRuntime.setDefaultVMInstall(vm, new NullProgressMonitor()); String javaHome = new File(TestVMType.getFakeJDKsLocation(), "11").getAbsolutePath(); prefs.setJavaHome(javaHome); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IPath rootFolder = root.getLocation().append("/projects/gradle/simple-gradle"); BuildConfiguration build = GradleProjectImporter.getBuildConfiguration(rootFolder.toFile().toPath()); assertEquals(vm.getInstallLocation().getAbsolutePath(), build.getJavaHome().get().getAbsolutePath()); } finally { prefs.setJavaHome(javaHomePreference); if (defaultVM != null) { JavaRuntime.setDefaultVMInstall(defaultVM, new NullProgressMonitor()); } } }
Example #3
Source File: FilteredTypesSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void processVMInstallType(IVMInstallType installType, List<String> locations, List<String> labels) { if (installType != null) { IVMInstall[] installs= installType.getVMInstalls(); boolean isMac= Platform.OS_MACOSX.equals(Platform.getOS()); final String HOME_SUFFIX= "/Home"; //$NON-NLS-1$ for (int i= 0; i < installs.length; i++) { String label= getFormattedLabel(installs[i].getName()); LibraryLocation[] libLocations= installs[i].getLibraryLocations(); if (libLocations != null) { processLibraryLocation(libLocations, label); } else { String filePath= installs[i].getInstallLocation().getAbsolutePath(); // on MacOS X install locations end in an additional // "/Home" segment; remove it if (isMac && filePath.endsWith(HOME_SUFFIX)) filePath= filePath.substring(0, filePath.length() - HOME_SUFFIX.length() + 1); locations.add(filePath); labels.add(label); } } } }
Example #4
Source File: AbstractJob.java From tlaplus with MIT License | 6 votes |
protected IVMInstall getVMInstall() { IVMInstall vmInstall = null; // Try using the very same VM the Toolbox is running with (e.g. // this avoids problems when the Toolbox runs with a 64bit VM, but // the nested VM is a 32bit one). final String javaHome = System.getProperty("java.home"); if (javaHome != null) { final IVMInstallType installType = new StandardVMType(); vmInstall = installType.createVMInstall("TLCModelCheckerNestedVM"); vmInstall.setInstallLocation(new File(javaHome)); return vmInstall; } // get OS default VM (determined by path) not necessarily the same // the toolbox is running with. return JavaRuntime.getDefaultVMInstall(); }
Example #5
Source File: TypeInfoViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void processVMInstallType(IVMInstallType installType, List locations, List labels) { if (installType != null) { IVMInstall[] installs= installType.getVMInstalls(); boolean isMac= Platform.OS_MACOSX.equals(Platform.getOS()); final String HOME_SUFFIX= "/Home"; //$NON-NLS-1$ for (int i= 0; i < installs.length; i++) { String label= getFormattedLabel(installs[i].getName()); LibraryLocation[] libLocations= installs[i].getLibraryLocations(); if (libLocations != null) { processLibraryLocation(libLocations, label); } else { String filePath= installs[i].getInstallLocation().getAbsolutePath(); // on MacOS X install locations end in an additional "/Home" segment; remove it if (isMac && filePath.endsWith(HOME_SUFFIX)) filePath= filePath.substring(0, filePath.length()- HOME_SUFFIX.length() + 1); locations.add(filePath); labels.add(label); } } } }
Example #6
Source File: JREContainerProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * @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 #7
Source File: ReorgCorrectionsSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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 #8
Source File: FilteredTypesSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void processVMInstallType(IVMInstallType installType, List<IPath> locations, List<String> labels) { if (installType != null) { IVMInstall[] installs= installType.getVMInstalls(); boolean isMac= Platform.OS_MACOSX.equals(Platform.getOS()); for (int i= 0; i < installs.length; i++) { String label= getFormattedLabel(installs[i].getName()); LibraryLocation[] libLocations= installs[i].getLibraryLocations(); if (libLocations != null) { processLibraryLocation(libLocations, label); } else { IPath filePath= Path.fromOSString(installs[i].getInstallLocation().getAbsolutePath()); // On MacOS X, install locations end in an additional "/Home" segment; remove it. if (isMac && "Home".equals(filePath.lastSegment())) //$NON-NLS-1$ filePath= filePath.removeLastSegments(1); locations.add(filePath); labels.add(label); } } } }
Example #9
Source File: NewJavaProjectWizardPageOne.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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 #10
Source File: ReportLauncherUtils.java From birt with Eclipse Public License 1.0 | 5 votes |
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( )] ); }
Example #11
Source File: MainProjectWizardPage.java From sarl with Apache License 2.0 | 5 votes |
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 #12
Source File: FilteredTypesSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * 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 #13
Source File: FilteredTypesSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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 #14
Source File: TypeInfoViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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 #15
Source File: TestVMType.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public TestVMInstall(IVMInstallType type, String id) { super(type, id); setNotify(false); setInstallLocation(new File(TestVMType.getFakeJDKsLocation(), id)); try { javadoc = new URL("https://docs.oracle.com/javase/" + id.replace("1.", "") + "/docs/api/"); } catch (MalformedURLException e) { JavaLanguageServerPlugin.logException(e.getMessage(), e); } }
Example #16
Source File: TestVMType.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public static void setTestJREAsDefault(String vmId) throws CoreException { IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(VMTYPE_ID); IVMInstall testVMInstall = vmInstallType.findVMInstall(vmId); if (!testVMInstall.equals(JavaRuntime.getDefaultVMInstall())) { // set the 1.8 test JRE as the new default JRE JavaRuntime.setDefaultVMInstall(testVMInstall, new NullProgressMonitor()); Hashtable<String, String> options = JavaCore.getOptions(); JavaCore.setComplianceOptions(vmId, options); JavaCore.setOptions(options); } JDTUtils.setCompatibleVMs(VMTYPE_ID); }
Example #17
Source File: JVMConfigurator.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
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 #18
Source File: JVMConfigurator.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public static boolean configureDefaultVM(String javaHome) throws CoreException { if (StringUtils.isBlank(javaHome)) { return false; } File jvmHome = new File(javaHome); if (jvmHome.isDirectory()) { IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall(); if (defaultVM != null && jvmHome.equals(defaultVM.getInstallLocation())) { return false; } } else { JavaLanguageServerPlugin.logInfo("java.home " + jvmHome + " is not a directory"); return false; } IVMInstall vm = findVM(jvmHome, null); 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(); } JavaLanguageServerPlugin.logInfo("Setting java.home " + jvmHome + " as default global VM"); JavaRuntime.setDefaultVMInstall(vm, new NullProgressMonitor()); JDTUtils.setCompatibleVMs(vm.getId()); return true; }