* * @param monitor progress monitor */ private void loadJRE(IProgressMonitor monitor) { IPath container = fTarget.getJREContainer(); monitor.beginTask(Messages.LoadTargetOperation_jreTaskName, 1); if (container != null) { IVMInstall jre = JavaRuntime.getVMInstall(container); if (jre != null) { IVMInstall def = JavaRuntime.getDefaultVMInstall(); if (!jre.equals(def)) { try { JavaRuntime.setDefaultVMInstall(jre, null); } catch (CoreException e) { } } } } monitor.done(); } /** * Resets the PDE workspace models with the new state information
@Override public String resolveValue(IDynamicVariable variable, String argument) throws CoreException { if (argument == null) { throw new CoreException(new Status(IStatus.ERROR, LaunchingPlugin.ID_PLUGIN, EnvironmentMessages.ExecutionEnvironmentVariableResolver_0)); } IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager(); IExecutionEnvironment env = manager.getEnvironment(argument); if (env == null) { throw new CoreException(new Status(IStatus.ERROR, LaunchingPlugin.ID_PLUGIN, NLS.bind(EnvironmentMessages.ExecutionEnvironmentVariableResolver_1, new String[]{argument}))); } IPath path = JavaRuntime.newJREContainerPath(env); IVMInstall jre = JavaRuntime.getVMInstall(path); if (jre == null) { throw new CoreException(new Status(IStatus.ERROR, LaunchingPlugin.ID_PLUGIN, NLS.bind(EnvironmentMessages.ExecutionEnvironmentVariableResolver_2, new String[]{argument}))); } return jre.getInstallLocation().getAbsolutePath(); }
private static IPath[] getClasspath(ILaunchConfiguration configuration) throws CoreException { IRuntimeClasspathEntry[] entries= JavaRuntime.computeUnresolvedRuntimeClasspath(configuration); entries= JavaRuntime.resolveRuntimeClasspath(entries, configuration); ArrayList<IPath> userEntries= new ArrayList<>(entries.length); boolean isModularConfig= JavaRuntime.isModularConfiguration(configuration); for (int i= 0; i < entries.length; i++) { int classPathProperty= entries[i].getClasspathProperty(); if ((!isModularConfig && classPathProperty == IRuntimeClasspathEntry.USER_CLASSES) || (isModularConfig && (classPathProperty == IRuntimeClasspathEntry.CLASS_PATH || classPathProperty == IRuntimeClasspathEntry.MODULE_PATH))) { String location= entries[i].getLocation(); if (location != null) { IPath entry= Path.fromOSString(location); if (!userEntries.contains(entry)) { userEntries.add(entry); } } } } return userEntries.toArray(new IPath[userEntries.size()]); }
private IVMInstall getVMInstall(String name) { 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++) { if (installs[i].getName().equals(name)) return installs[i]; } } return JavaRuntime.getDefaultVMInstall(); }
protected void selectJRE(String typeID, String vmName) { if (typeID == null) { fJREBlock.setPath(JavaRuntime.newDefaultJREContainerPath()); } else { fJREBlock.setPath(JavaRuntime.newJREContainerPath(typeID, vmName)); } }
fRequiredJREFound= vmInstall != null; if (vmInstall != null) { IVMInstall install= JavaRuntime.getVMInstall(fProject); // can be null monitor.beginTask(CorrectionMessages.ReorgCorrectionsSubProcessor_50_compliance_operation, 4); IVMInstall defaultVM= JavaRuntime.getDefaultVMInstall(); // can be null if (defaultVM != null && !defaultVM.equals(install)) { IPath newPath= new Path(JavaRuntime.JRE_CONTAINER); JavaRuntime.setDefaultVMInstall(vmInstall, new SubProgressMonitor(monitor, 3), true); return false; fRequiredJREFound= bestEE != null; if (bestEE != null) { IPath newPath= JavaRuntime.newJREContainerPath(bestEE); boolean classpathUpdated= ClasspathVMUtil.updateClasspath(newPath, fProject, monitor); return !classpathUpdated;
private String getDefaultJVMName() { IVMInstall install= JavaRuntime.getDefaultVMInstall(); if (install != null) { return install.getName(); } else { return NewWizardMessages.NewJavaProjectWizardPageOne_UnknownDefaultJRE_name; } }
public static IExecutionEnvironment getExecutionEnvironment(String id) { IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager(); return manager.getEnvironment(id); }
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; }
public static String getVMInstallName(IExecutionEnvironment ee) throws CoreException { IPath containerPath = JavaRuntime.newJREContainerPath(ee); IVMInstall vmi = JavaRuntime.getVMInstall(containerPath); if (vmi == null) throw new CoreException(createErrorStatus(NLS.bind(UtilMessages.VMHelper_noJreForExecEnv, ee.getId()))); return vmi.getName(); }
private static IPath[] getClasspath(ILaunchConfiguration configuration) throws CoreException { IRuntimeClasspathEntry[] entries= JavaRuntime.computeUnresolvedRuntimeClasspath(configuration); entries= JavaRuntime.resolveRuntimeClasspath(entries, configuration); ArrayList<IPath> userEntries= new ArrayList<>(entries.length); for (int i= 0; i < entries.length; i++) { if (entries[i].getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES) { String location= entries[i].getLocation(); if (location != null) { IPath entry= Path.fromOSString(location); if (!userEntries.contains(entry)) { userEntries.add(entry); } } } } return userEntries.toArray(new IPath[userEntries.size()]); }
public void widgetSelected(SelectionEvent e) { setPath(JavaRuntime.newJREContainerPath(getEnvironment())); firePropertyChange(); } });
public String[] computeDefaultRuntimeClassPath(IJavaProject project) throws CoreException { return JavaRuntime.computeDefaultRuntimeClassPath(project); }
protected void loadJREInfo(Preferences pref, IProgressMonitor monitor) { ITargetJRE jreInfo = fTarget.getTargetJREInfo(); monitor.beginTask(PDECoreMessages.LoadTargetOperation_jreTaskName, 1); if (jreInfo != null) { String jre = jreInfo.getCompatibleJRE(); IVMInstall install = JavaRuntime.getDefaultVMInstall(); if (install != null && !jre.equals(install.getName())) try { JavaRuntime.setDefaultVMInstall(getVMInstall(jre), null); } catch (CoreException e) { } } monitor.done(); }
/** * Returns whether the VM install with the specified id was contributed via * the vmInstalls extension point. * * @param id VM id * @return whether the VM install was contributed via extension point * @since 3.2 */ public static boolean isContributedVMInstall(String id) { getVMInstallTypes(); // ensure VMs are initialized return fgContributedVMs.contains(id); }
@Override public IRuntimeClasspathEntry[] resolveClasspath(IRuntimeClasspathEntry[] entries, ILaunchConfiguration configuration) throws CoreException { // use an ordered set to avoid duplicates Set<IRuntimeClasspathEntry> all = new LinkedHashSet<IRuntimeClasspathEntry>(entries.length); for (int i = 0; i < entries.length; i++) { IRuntimeClasspathEntry[] resolved =JavaRuntime.resolveRuntimeClasspathEntry(entries[i], configuration); for (int j = 0; j < resolved.length; j++) { all.add(resolved[j]); } } return all.toArray(new IRuntimeClasspathEntry[all.size()]); }
public IRuntimeClasspathEntry[] computeUnresolvedRuntimeClasspath(IJavaProject project) throws CoreException { return JavaRuntime.computeUnresolvedRuntimeClasspath(project); }
public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException { boolean useDefault = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_SOURCE_PATH, true); IRuntimeClasspathEntry[] entries = null; if (useDefault) { // the default source lookup path is the classpath of the associated project IJavaProject project = JavaRuntime.getJavaProject(configuration); entries = JavaRuntime.computeUnresolvedRuntimeClasspath(project); } else { // recover persisted source path entries = recoverRuntimePath(configuration, IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH); } return entries; } }
public static boolean is50OrHigherJRE(IJavaProject project) throws CoreException { IVMInstall vmInstall= JavaRuntime.getVMInstall(project); if (!(vmInstall instanceof IVMInstall2)) return true; // assume 5.0. String compliance= getCompilerCompliance((IVMInstall2) vmInstall, null); if (compliance == null) return true; // assume 5.0 return compliance.startsWith(JavaCore.VERSION_1_5) || compliance.startsWith(JavaCore.VERSION_1_6); }
/** * Creates and returns a classpath entry describing * the default JRE container entry. * * @return a new IClasspathEntry that describes the default JRE container entry * @since 2.0 */ public static IClasspathEntry getDefaultJREContainerEntry() { return JavaCore.newContainerEntry(newDefaultJREContainerPath()); }