org.eclipse.jdt.launching.IVMInstall Java Examples

The following examples show how to use org.eclipse.jdt.launching.IVMInstall. 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: AbstractJob.java    From tlaplus with MIT License 6 votes vote down vote up
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 #2
Source File: FilteredTypesSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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 #3
Source File: JreDetector.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
/** Return the best Execution Environment ID for the given VM. */
@VisibleForTesting
static String determineExecutionEnvironment(
    IExecutionEnvironmentsManager manager, IVMInstall install) {
  // A VM may be marked for several Java execution environments (e.g., a Java 9 VM is compatible
  // with Java 8 and Java 7).  So check the EEs in order of most recent to oldest to return the
  // most specific possible.
  for (String environmentId : JAVASE_BY_RECENCY) {
    IExecutionEnvironment environment = manager.getEnvironment(environmentId);
    if (environment == null) {
      continue;
    }
    if (environment.getDefaultVM() == install) {
      return environment.getId();
    }
    for (IVMInstall vm : environment.getCompatibleVMs()) {
      if (vm == install) {
        return environmentId;
      }
    }
  }
  return "UNKNOWN";
}
 
Example #4
Source File: JreDetector.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
static boolean isDevelopmentKit(IExecutionEnvironmentsManager manager, IVMInstall install) {
  File root = install.getInstallLocation();

  String executionEnvironment = determineExecutionEnvironment(manager, install);
  switch (executionEnvironment) {
    case JAVASE7:
    case JAVASE8:
      // JDKs on Windows, Linux, and MacOS all have lib/tools.jar
      File tools = new File(root, "lib/tools.jar");
      return tools.exists();

    case JAVASE9:
    case JAVASE10:
      // JDKs on Windows, Linux, and MacOS all have jmods/java.compiler.mod
      File compilerModule = new File(root, "jmods/java.compiler.jmod");
      return compilerModule.exists();

    default:
      logger.log(Level.WARNING, "Unknown Java installation type: " + executionEnvironment);
      return false;
  }
}
 
Example #5
Source File: SARLRuntimeEnvironmentTab.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Replies if the selected configuration has a valid version for
 * a SARL application.
 *
 * @param config the configuration.
 * @return <code>true</code> if the JRE is compatible with SARL.
 */
protected boolean isValidJREVersion(ILaunchConfiguration config) {
	final IVMInstall install = this.fJREBlock.getJRE();
	if (install instanceof IVMInstall2) {
		final String version = ((IVMInstall2) install).getJavaVersion();
		if (version == null) {
			setErrorMessage(MessageFormat.format(
					Messages.RuntimeEnvironmentTab_3, install.getName()));
			return false;
		}
		if (!Utils.isCompatibleJDKVersionWhenInSARLProjectClasspath(version)) {
			setErrorMessage(MessageFormat.format(
					Messages.RuntimeEnvironmentTab_4,
					install.getName(),
					version,
					SARLVersion.MINIMAL_JDK_VERSION_IN_SARL_PROJECT_CLASSPATH,
					SARLVersion.INCOMPATIBLE_JDK_VERSION_IN_SARL_PROJECT_CLASSPATH));
			return false;
		}
	}
	return true;
}
 
Example #6
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 #7
Source File: JavaProjectSetupUtil.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static void makeJava7Default() {
	if (!isJava7Default) {
		IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
		IExecutionEnvironment[] environments = manager.getExecutionEnvironments();
		for (int i = 0; i < environments.length; i++) {
			IExecutionEnvironment environment = environments[i];
			if (environment.getId().equals("JavaSE-1.6") && environment.getDefaultVM() == null) {
				IVMInstall[] compatibleVMs = environment.getCompatibleVMs();
				for (IVMInstall ivmInstall : compatibleVMs) {
					if (ivmInstall instanceof IVMInstall2) {
						IVMInstall2 install2 = (IVMInstall2) ivmInstall;
						if (install2.getJavaVersion().startsWith("1.7")) {
							environment.setDefaultVM(ivmInstall);
						}
					}
				}
			}
		}
		isJava7Default = true;
	}
}
 
Example #8
Source File: JavaProjectSetupUtil.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static void makeJava7Default() {
	if (!isJava7Default) {
		IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
		IExecutionEnvironment[] environments = manager.getExecutionEnvironments();
		for (int i = 0; i < environments.length; i++) {
			IExecutionEnvironment environment = environments[i];
			if (environment.getId().equals("JavaSE-1.6") && environment.getDefaultVM() == null) {
				IVMInstall[] compatibleVMs = environment.getCompatibleVMs();
				for (IVMInstall ivmInstall : compatibleVMs) {
					if (ivmInstall instanceof IVMInstall2) {
						IVMInstall2 install2 = (IVMInstall2) ivmInstall;
						if (install2.getJavaVersion().startsWith("1.7")) {
							environment.setDefaultVM(ivmInstall);
						}
					}
				}
			}
		}
		isJava7Default = true;
	}
}
 
Example #9
Source File: ImportPlatformWizard.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 6 votes vote down vote up
protected void fixRuntimeEnvironment( String platformDir )
{
	IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( "platform" );
	IJavaProject javaProject = JavaCore.create( project );
	IVMInstall javaInstall = null;
	try
	{
		if(javaProject.isOpen())
		{
		javaInstall = JavaRuntime.getVMInstall( javaProject );
	}
	}
	catch( CoreException e )
	{
		throw new IllegalStateException( e );
	}
	if( javaInstall != null )
	{
		setHeapSize( javaInstall );
	}
}
 
Example #10
Source File: FilteredTypesSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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 #11
Source File: JVMConfigurator.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static boolean setDefaultEnvironmentVM(IVMInstall vm, String name) {
	IExecutionEnvironment environment = getExecutionEnvironment(name);
	if (environment != null) {
		if (Objects.equals(vm, environment.getDefaultVM())) {
			return true;
		}
		IVMInstall[] compatibleVMs = environment.getCompatibleVMs();
		for (IVMInstall compatibleVM : compatibleVMs) {
			if (compatibleVM.equals(vm)) {
				if (!environment.isStrictlyCompatible(vm)) {
					JavaLanguageServerPlugin.logInfo("Runtime at '" + vm.getInstallLocation().toString() + "' is not strictly compatible with the '" + name + "' environment");
				}
				JavaLanguageServerPlugin.logInfo("Setting " + compatibleVM.getInstallLocation() + " as '" + name + "' environment (id:" + compatibleVM.getId() + ")");
				environment.setDefaultVM(compatibleVM);
				return true;
			}
		}
	}
	return false;
}
 
Example #12
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 #13
Source File: JVMConfigurator.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
public static void configureJVMSettings(IJavaProject javaProject, IVMInstall vmInstall) {
	if (javaProject == null) {
		return;
	}
	String version = "";
	if (vmInstall instanceof AbstractVMInstall) {
		AbstractVMInstall jvm = (AbstractVMInstall) vmInstall;
		version = jvm.getJavaVersion();
		long jdkLevel = CompilerOptions.versionToJdkLevel(jvm.getJavaVersion());
		String compliance = CompilerOptions.versionFromJdkLevel(jdkLevel);
		Map<String, String> options = javaProject.getOptions(false);
		JavaCore.setComplianceOptions(compliance, options);
	}
	;
	if (JavaCore.compareJavaVersions(version, JavaCore.latestSupportedJavaVersion()) >= 0) {
		//Enable Java preview features for the latest JDK release by default and stfu about it
		javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
		javaProject.setOption(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
	} else {
		javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.DISABLED);
	}

}
 
Example #14
Source File: NewJavaProjectWizardPageOne.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private String getDefaultEEName() {
	IVMInstall defaultVM= JavaRuntime.getDefaultVMInstall();

	IExecutionEnvironment[] environments= JavaRuntime.getExecutionEnvironmentsManager().getExecutionEnvironments();
	if (defaultVM != null) {
		for (int i= 0; i < environments.length; i++) {
			IVMInstall eeDefaultVM= environments[i].getDefaultVM();
			if (eeDefaultVM != null && defaultVM.getId().equals(eeDefaultVM.getId()))
				return environments[i].getId();
		}
	}

	String defaultCC=JavaModelUtil.VERSION_LATEST;
	if (defaultVM instanceof IVMInstall2)
		defaultCC= JavaModelUtil.getCompilerCompliance((IVMInstall2)defaultVM, defaultCC);

	for (int i= 0; i < environments.length; i++) {
		String eeCompliance= JavaModelUtil.getExecutionEnvironmentCompliance(environments[i]);
		if (defaultCC.endsWith(eeCompliance))
			return environments[i].getId();
	}

	return "JavaSE-1.7"; //$NON-NLS-1$
}
 
Example #15
Source File: JavaModelUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Checks if the JRE of the given project or workspace default JRE have source compliance 1.5 or
 * greater.
 *
 * @param project the project to test or <code>null</code> to test the workspace JRE
 * @return <code>true</code> if the JRE of the given project or workspace default JRE have
 *         source compliance 1.5 or greater.
 * @throws CoreException if unable to determine the project's VM install
 */
public static boolean is50OrHigherJRE(IJavaProject project) throws CoreException {
	IVMInstall vmInstall;
	if (project == null) {
		vmInstall= JavaRuntime.getDefaultVMInstall();
	} else {
		vmInstall= JavaRuntime.getVMInstall(project);
	}
	if (!(vmInstall instanceof IVMInstall2))
		return true; // assume 1.5.

	String compliance= getCompilerCompliance((IVMInstall2) vmInstall, null);
	if (compliance == null)
		return true; // assume 1.5
	return is50OrHigher(compliance);
}
 
Example #16
Source File: ProjectCommand.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Gets the project settings.
 *
 * @param uri
 *                        Uri of the source/class file that needs to be queried.
 * @param settingKeys
 *                        the settings we want to query, for example:
 *                        ["org.eclipse.jdt.core.compiler.compliance",
 *                        "org.eclipse.jdt.core.compiler.source"].
 *                        Besides the options defined in JavaCore, the following keys can also be used:
 *                        - "org.eclipse.jdt.ls.core.vm.location": Get the location of the VM assigned to build the given Java project
 * @return A <code>Map<string, string></code> with all the setting keys and
 *         their values.
 * @throws CoreException
 * @throws URISyntaxException
 */
public static Map<String, String> getProjectSettings(String uri, List<String> settingKeys) throws CoreException, URISyntaxException {
	IJavaProject javaProject = getJavaProjectFromUri(uri);
	Map<String, String> settings = new HashMap<>();
	for (String key : settingKeys) {
		switch(key) {
			case VM_LOCATION:
				IVMInstall vmInstall = JavaRuntime.getVMInstall(javaProject);
				if (vmInstall == null) {
					continue;
				}
				File location = vmInstall.getInstallLocation();
				if (location == null) {
					continue;
				}
				settings.putIfAbsent(key, location.getAbsolutePath());
				break;
			default:
				settings.putIfAbsent(key, javaProject.getOption(key, true));
				break;
		}
	}
	return settings;
}
 
Example #17
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 #18
Source File: GradleProjectImporterTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
@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 #19
Source File: TypeInfoViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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 #20
Source File: ProcessUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
public static String getJavaExecutableForVMInstall(IVMInstall vmInstall) throws CoreException {

    assert vmInstall != null;

    File vmInstallLocation = vmInstall.getInstallLocation();

    if (vmInstallLocation == null) {
      throw new CoreException(new Status(Status.ERROR, CorePlugin.PLUGIN_ID,
          "Unable to determine the path for the JVM " + vmInstall.getName()
              + ". Please verify that this JVM is installed properly by inspecting your project's build path."));
    }

    File javaExecutable = StandardVMType.findJavaExecutable(vmInstallLocation);

    if (javaExecutable == null || !javaExecutable.exists()) {
      throw new CoreException(new Status(Status.ERROR, CorePlugin.PLUGIN_ID,
          "Unable to find a java executable for the JVM   " + vmInstall.getName() + " located at "
              + vmInstallLocation.getAbsolutePath()
              + ". Please verify that this JVM is installed properly by inspecting your project's build path."));
    }

    return javaExecutable.getAbsolutePath();
  }
 
Example #21
Source File: ComplianceConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Sets the default compiler compliance options based on the current default JRE in the
 * workspace.
 * 
 * @since 3.5
 */
private void setDefaultCompilerComplianceValues() {
	IVMInstall defaultVMInstall= JavaRuntime.getDefaultVMInstall();
	if (defaultVMInstall instanceof IVMInstall2 && isOriginalDefaultCompliance()) {
		String complianceLevel= JavaModelUtil.getCompilerCompliance((IVMInstall2)defaultVMInstall, JavaCore.VERSION_1_4);
		Map<String, String> complianceOptions= new HashMap<String, String>();
		JavaModelUtil.setComplianceOptions(complianceOptions, complianceLevel);
		setDefaultValue(PREF_COMPLIANCE, complianceOptions.get(PREF_COMPLIANCE.getName()));
		setDefaultValue(PREF_PB_ASSERT_AS_IDENTIFIER, complianceOptions.get(PREF_PB_ASSERT_AS_IDENTIFIER.getName()));
		setDefaultValue(PREF_PB_ENUM_AS_IDENTIFIER, complianceOptions.get(PREF_PB_ENUM_AS_IDENTIFIER.getName()));
		setDefaultValue(PREF_SOURCE_COMPATIBILITY, complianceOptions.get(PREF_SOURCE_COMPATIBILITY.getName()));
		setDefaultValue(PREF_CODEGEN_TARGET_PLATFORM, complianceOptions.get(PREF_CODEGEN_TARGET_PLATFORM.getName()));
	}
}
 
Example #22
Source File: ReportLauncherUtils.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public static IVMInstall getVMInstall( String name )
{
	if ( name != null )
	{
		IVMInstall[] installs = getAllVMInstances( );
		for ( int i = 0; i < installs.length; i++ )
		{
			if ( installs[i].getName( ).equals( name ) )
				return installs[i];
		}
	}
	return JavaRuntime.getDefaultVMInstall( );
}
 
Example #23
Source File: NewJavaProjectWizardPageOne.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private String getDefaultJVMName() {
	IVMInstall install= JavaRuntime.getDefaultVMInstall();
	if (install != null) {
		return install.getName();
	} else {
		return NewWizardMessages.NewJavaProjectWizardPageOne_UnknownDefaultJRE_name;
	}
}
 
Example #24
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 #25
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( )] );
}
 
Example #26
Source File: PasteAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private String getVMVersion(IVMInstall vm) {
	if (vm instanceof IVMInstall2) {
		IVMInstall2 vm2= (IVMInstall2) vm;
		return JavaModelUtil.getCompilerCompliance(vm2, null);
	} else {
		return null;
	}
}
 
Example #27
Source File: UIDesignerServerManager.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
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 #28
Source File: RuntimeUtils.java    From JReFrameworker with MIT License 5 votes vote down vote up
public static boolean isRuntimeJar(File jar) throws IOException {
	IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
	LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);
	for (LibraryLocation library : locations) {
		File runtime = JavaCore.newLibraryEntry(library.getSystemLibraryPath(), null, null).getPath().toFile().getCanonicalFile();
		if(runtime.equals(jar.getCanonicalFile())){
			return true;
		}
	}
	return false;
}
 
Example #29
Source File: ProcessUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Computes the fully qualified path to the java executable for the JRE/JDK used by this project.
 *
 * @param javaProject
 * @return the path to the JRE/JDK java (executable) used on this project
 * @throws CoreException
 */
public static String computeJavaExecutableFullyQualifiedPath(IJavaProject javaProject) throws CoreException {
  IVMInstall projectVMInstall = JavaRuntime.getVMInstall(javaProject);

  if (projectVMInstall == null) {
    throw new CoreException(new Status(Status.ERROR, CorePlugin.PLUGIN_ID, "Unable to locate the JVM for project "
        + javaProject.getElementName()
        + ". Please verify that you have a project-level JVM installed by inspecting your project's build path."));
  }

  return getJavaExecutableForVMInstall(projectVMInstall);
}
 
Example #30
Source File: NewJavaProjectWizardPageOne.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public IVMInstall getSelectedJVM() {
	if (fUseProjectJRE.isSelected()) {
		int index= fJRECombo.getSelectionIndex();
		if (index >= 0 && index < fInstalledJVMs.length) { // paranoia
			return fInstalledJVMs[index];
		}
	} else if (fUseEEJRE.isSelected()) {

	}
	return null;
}