org.eclipse.jdt.internal.launching.StandardVMType Java Examples
The following examples show how to use
org.eclipse.jdt.internal.launching.StandardVMType.
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: 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 #2
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 #3
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; }
Example #4
Source File: OpenH2ConsoleHandler.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected String javaBinaryLocation() throws FileNotFoundException { File javaBinaryPath = StandardVMType.findJavaExecutable(JavaRuntime.getDefaultVMInstall().getInstallLocation()); if (javaBinaryPath == null || !javaBinaryPath.exists()) { throw new FileNotFoundException( String.format("Java binary not found at '%s'", javaBinaryPath.getAbsolutePath())); } return javaBinaryPath.getAbsolutePath(); }
Example #5
Source File: UIDesignerServerManager.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected String javaBinaryLocation() throws FileNotFoundException { IVMInstall defaultVMInstall = JavaRuntime.getDefaultVMInstall(); if (defaultVMInstall == null) { throw new FileNotFoundException("Default VM not installed"); } File javaBinaryPath = StandardVMType.findJavaExecutable(defaultVMInstall.getInstallLocation()); if (javaBinaryPath == null) { throw new FileNotFoundException("Java binary not configured"); } else if (!javaBinaryPath.exists()) { throw new FileNotFoundException( String.format("Java binary not found at '%s'", javaBinaryPath.getAbsolutePath())); } return javaBinaryPath.getAbsolutePath(); }
Example #6
Source File: JREContainerProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
/** * @return JRE container path {@link IPath} for standard VM "J2SE-1.5" */ protected static IPath newJRE15ContainerPath() { return newJREContainerPath(StandardVMType.ID_STANDARD_VM_TYPE, JavaVersion.JAVA5.getBree()); }
Example #7
Source File: JavaProjectSetupUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public static void addJreClasspathEntry(IJavaProject javaProject, String bree) throws JavaModelException { IPath jreContainerPath = JavaRuntime.newJREContainerPath(StandardVMType.ID_STANDARD_VM_TYPE, bree); addToClasspath(javaProject, JavaCore.newContainerEntry(jreContainerPath)); }
Example #8
Source File: JavaProjectSetupUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public static void addJreClasspathEntry(IJavaProject javaProject, String bree) throws JavaModelException { IPath jreContainerPath = JavaRuntime.newJREContainerPath(StandardVMType.ID_STANDARD_VM_TYPE, bree); addToClasspath(javaProject, JavaCore.newContainerEntry(jreContainerPath)); }
Example #9
Source File: JavaProjectSetupUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
/** * @since 2.17 */ public static void addJreClasspathEntry(IJavaProject javaProject, String bree, boolean build) throws JavaModelException { IPath jreContainerPath = JavaRuntime.newJREContainerPath(StandardVMType.ID_STANDARD_VM_TYPE, bree); addToClasspath(javaProject, JavaCore.newContainerEntry(jreContainerPath), build); }
Example #10
Source File: JREContainerProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 2 votes |
/** * @since 2.8 * @return JRE container path {@link IPath} for standard VM {@value #PREFERRED_BREE} */ protected static IPath newPreferredContainerPath() { return newJREContainerPath(StandardVMType.ID_STANDARD_VM_TYPE, PREFERRED_BREE); }