当前位置: 首页>>代码示例>>Java>>正文


Java IVMInstall2类代码示例

本文整理汇总了Java中org.eclipse.jdt.launching.IVMInstall2的典型用法代码示例。如果您正苦于以下问题:Java IVMInstall2类的具体用法?Java IVMInstall2怎么用?Java IVMInstall2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IVMInstall2类属于org.eclipse.jdt.launching包,在下文中一共展示了IVMInstall2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: eclipseAndJvmSupportedJavaVersion

import org.eclipse.jdt.launching.IVMInstall2; //导入依赖的package包/类
/** TopCoder supports java 1.8. */
private static String eclipseAndJvmSupportedJavaVersion() {
  boolean jvm18Installed = false;
  for(IVMInstallType vm : JavaRuntime.getVMInstallTypes()) {
    for(IVMInstall inst : vm.getVMInstalls()) {
      if(inst instanceof IVMInstall2) {
        String jvmVersion = ((IVMInstall2) inst).getJavaVersion();
        String[] jvmVersionParts  = jvmVersion.split("\\.");
        int major = Integer.parseInt(jvmVersionParts[0]);
        int minor = Integer.parseInt(jvmVersionParts[1]);
        if((major == 1 && minor >= 8) || major >=2) {
          jvm18Installed = true;
        }
      }
    }
  }

  Version jdtVersion = JavaCore.getJavaCore().getBundle().getVersion();
  boolean jdtSupports18 = jdtVersion.getMajor() >= 4
      || (jdtVersion.getMajor() == 3 && jdtVersion.getMinor() >= 10)
      || (jdtVersion.getMajor() == 3 && jdtVersion.getMinor() >= 9 && jdtVersion.getMicro() >= 50);

  return jvm18Installed && jdtSupports18 ? "1.8" : "1.7";
}
 
开发者ID:fmoraes74,项目名称:eclipseforces,代码行数:25,代码来源:JavaLanguageSupport.java

示例2: is50OrHigherJRE

import org.eclipse.jdt.launching.IVMInstall2; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:JavaModelUtil.java

示例3: getCompilerCompliance

import org.eclipse.jdt.launching.IVMInstall2; //导入依赖的package包/类
public static String getCompilerCompliance(IVMInstall2 vMInstall, String defaultCompliance) {
	String version= vMInstall.getJavaVersion();
	if (version == null) {
		return defaultCompliance;
	} else if (version.startsWith(JavaCore.VERSION_1_8)) {
		return JavaCore.VERSION_1_8;
	} else if (version.startsWith(JavaCore.VERSION_1_7)) {
		return JavaCore.VERSION_1_7;
	} else if (version.startsWith(JavaCore.VERSION_1_6)) {
		return JavaCore.VERSION_1_6;
	} else if (version.startsWith(JavaCore.VERSION_1_5)) {
		return JavaCore.VERSION_1_5;
	} else if (version.startsWith(JavaCore.VERSION_1_4)) {
		return JavaCore.VERSION_1_4;
	} else if (version.startsWith(JavaCore.VERSION_1_3)) {
		return JavaCore.VERSION_1_3;
	} else if (version.startsWith(JavaCore.VERSION_1_2)) {
		return JavaCore.VERSION_1_3;
	} else if (version.startsWith(JavaCore.VERSION_1_1)) {
		return JavaCore.VERSION_1_3;
	}
	return defaultCompliance;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:JavaModelUtil.java

示例4: getDefaultEEName

import org.eclipse.jdt.launching.IVMInstall2; //导入依赖的package包/类
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$
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:NewJavaProjectWizardPageOne.java

示例5: is50OrHigherJRE

import org.eclipse.jdt.launching.IVMInstall2; //导入依赖的package包/类
/**
 * 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 compliance.startsWith(JavaCore.VERSION_1_5)
			|| compliance.startsWith(JavaCore.VERSION_1_6)
			|| compliance.startsWith(JavaCore.VERSION_1_7);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:27,代码来源:JavaModelUtil.java

示例6: getCompilerCompliance

import org.eclipse.jdt.launching.IVMInstall2; //导入依赖的package包/类
public static String getCompilerCompliance(IVMInstall2 vMInstall, String defaultCompliance) {
	String version= vMInstall.getJavaVersion();
	if (version == null) {
		return defaultCompliance;
	} else if (version.startsWith(JavaCore.VERSION_1_7)) {
		return JavaCore.VERSION_1_7;
	} else if (version.startsWith(JavaCore.VERSION_1_6)) {
		return JavaCore.VERSION_1_6;
	} else if (version.startsWith(JavaCore.VERSION_1_5)) {
		return JavaCore.VERSION_1_5;
	} else if (version.startsWith(JavaCore.VERSION_1_4)) {
		return JavaCore.VERSION_1_4;
	} else if (version.startsWith(JavaCore.VERSION_1_3)) {
		return JavaCore.VERSION_1_3;
	} else if (version.startsWith(JavaCore.VERSION_1_2)) {
		return JavaCore.VERSION_1_3;
	} else if (version.startsWith(JavaCore.VERSION_1_1)) {
		return JavaCore.VERSION_1_3;
	}
	return defaultCompliance;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:22,代码来源:JavaModelUtil.java

示例7: enforcePreferredCompilerCompliance

import org.eclipse.jdt.launching.IVMInstall2; //导入依赖的package包/类
/**
 * Makes the given project use JDK 6 (or more specifically,
 * {@link AdtConstants#COMPILER_COMPLIANCE_PREFERRED} as the compilation
 * target, regardless of what the default IDE JDK level is, provided a JRE
 * of the given level is installed.
 *
 * @param javaProject the Java project
 * @throws CoreException if the IDE throws an exception setting the compiler
 *             level
 */
@SuppressWarnings("restriction") // JDT API for setting compliance options
public static void enforcePreferredCompilerCompliance(IJavaProject javaProject)
        throws CoreException {
    String compliance = javaProject.getOption(JavaCore.COMPILER_COMPLIANCE, true);
    if (compliance == null ||
            JavaModelUtil.isVersionLessThan(compliance, COMPILER_COMPLIANCE_PREFERRED)) {
        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];
                if (install instanceof IVMInstall2) {
                    IVMInstall2 install2 = (IVMInstall2) install;
                    // Java version can be 1.6.0, and preferred is 1.6
                    if (install2.getJavaVersion().startsWith(COMPILER_COMPLIANCE_PREFERRED)) {
                        Map<String, String> options = javaProject.getOptions(false);
                        JavaCore.setComplianceOptions(COMPILER_COMPLIANCE_PREFERRED, options);
                        JavaModelUtil.setDefaultClassfileOptions(options,
                                COMPILER_COMPLIANCE_PREFERRED);
                        javaProject.setOptions(options);
                        return;
                    }
                }
            }
        }
    }
}
 
开发者ID:thahn0720,项目名称:agui_eclipse_plugin,代码行数:39,代码来源:ProjectHelper.java

示例8: getVMVersion

import org.eclipse.jdt.launching.IVMInstall2; //导入依赖的package包/类
private String getVMVersion(IVMInstall vm) {
	if (vm instanceof IVMInstall2) {
		IVMInstall2 vm2= (IVMInstall2) vm;
		return JavaModelUtil.getCompilerCompliance(vm2, null);
	} else {
		return null;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:PasteAction.java

示例9: isRequiredOrGreaterVMInstall

import org.eclipse.jdt.launching.IVMInstall2; //导入依赖的package包/类
private boolean isRequiredOrGreaterVMInstall(IVMInstall install) {
	if (install instanceof IVMInstall2) {
		String compliance= JavaModelUtil.getCompilerCompliance((IVMInstall2) install, JavaCore.VERSION_1_3);
		return !JavaModelUtil.isVersionLessThan(compliance, fRequiredVersion);
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:ReorgCorrectionsSubProcessor.java

示例10: getVMInstallCompliance

import org.eclipse.jdt.launching.IVMInstall2; //导入依赖的package包/类
private String getVMInstallCompliance(IVMInstall install) {
	if (install instanceof IVMInstall2) {
		String compliance= JavaModelUtil.getCompilerCompliance((IVMInstall2) install, JavaCore.VERSION_1_3);
		return compliance;
	}
	return JavaCore.VERSION_1_1;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:ReorgCorrectionsSubProcessor.java

示例11: validateComplianceStatus

import org.eclipse.jdt.launching.IVMInstall2; //导入依赖的package包/类
private void validateComplianceStatus() {
		if (fJRE50InfoText != null && !fJRE50InfoText.isDisposed()) {
			boolean isVisible= false;
			String compliance= getStoredValue(PREF_COMPLIANCE); // get actual value
			IVMInstall install= null;
			if (fProject != null) { // project specific settings: only test if a 50 JRE is installed
				try {
					install= JavaRuntime.getVMInstall(JavaCore.create(fProject));
				} catch (CoreException e) {
					JavaPlugin.log(e);
				}
			} else {
				install= JavaRuntime.getDefaultVMInstall();
			}
			if (install instanceof IVMInstall2) {
				String compilerCompliance= JavaModelUtil.getCompilerCompliance((IVMInstall2) install, compliance);
				if (!compilerCompliance.equals(compliance)) { // Discourage using compiler with version other than compliance
					String[] args= { getVersionLabel(compliance), getVersionLabel(compilerCompliance) };
					if (fProject == null) {
						fJRE50InfoText.setText(Messages.format(PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info, args));
					} else {
						fJRE50InfoText.setText(Messages.format(PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info_project, args));
					}
					isVisible= true;
				}
			}
			
//			String source= getValue(PREF_SOURCE_COMPATIBILITY);
//			if (VERSION_1_8.equals(source)) {
//				fJRE50InfoText.setText("This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP."); //$NON-NLS-1$
//				isVisible= true;
//			}
			
			fJRE50InfoText.setVisible(isVisible);
			fJRE50InfoImage.setImage(isVisible ? JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING) : null);
			fJRE50InfoImage.getParent().layout();
		}
	}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:39,代码来源:ComplianceConfigurationBlock.java

示例12: setDefaultCompilerComplianceValues

import org.eclipse.jdt.launching.IVMInstall2; //导入依赖的package包/类
/**
 * 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()));
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:ComplianceConfigurationBlock.java

示例13: getDefaultEEName

import org.eclipse.jdt.launching.IVMInstall2; //导入依赖的package包/类
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;
	if (defaultVM instanceof IVMInstall2) {
		defaultCC= JavaModelUtil.getCompilerCompliance((IVMInstall2)defaultVM, JavaCore.VERSION_1_4);
	} else {
		defaultCC= JavaCore.VERSION_1_4;
	}

	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.6"; //$NON-NLS-1$
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:28,代码来源:NewJavaProjectWizardPageOne.java

示例14: validateComplianceStatus

import org.eclipse.jdt.launching.IVMInstall2; //导入依赖的package包/类
private void validateComplianceStatus() {
	if (fJRE50InfoText != null && !fJRE50InfoText.isDisposed()) {
		boolean isVisible= false;
		String compliance= getStoredValue(PREF_COMPLIANCE); // get actual value
		IVMInstall install= null;
		if (fProject != null) { // project specific settings: only test if a 50 JRE is installed
			try {
				install= JavaRuntime.getVMInstall(JavaCore.create(fProject));
			} catch (CoreException e) {
				JavaPlugin.log(e);
			}
		} else {
			install= JavaRuntime.getDefaultVMInstall();
		}
		if (install instanceof IVMInstall2) {
			String compilerCompliance= JavaModelUtil.getCompilerCompliance((IVMInstall2) install, compliance);
			if (!compilerCompliance.equals(compliance)) { // Discourage using compiler with version other than compliance
				String[] args= { getVersionLabel(compliance), getVersionLabel(compilerCompliance) };
				if (fProject == null) {
					fJRE50InfoText.setText(Messages.format(PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info, args));
				} else {
					fJRE50InfoText.setText(Messages.format(PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info_project, args));
				}
				isVisible= true;
			}
		}
		fJRE50InfoText.setVisible(isVisible);
		fJRE50InfoImage.setImage(isVisible ? JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING) : null);
		fJRE50InfoImage.getParent().layout();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:32,代码来源:ComplianceConfigurationBlock.java

示例15: getJavaVersion

import org.eclipse.jdt.launching.IVMInstall2; //导入依赖的package包/类
/**
 * Returns the version of the current VM in use
 * 
 * @return the VM version
 */
private double getJavaVersion( )
{
	String version = null;
	if ( fVMInstance instanceof IVMInstall2 )
	{
		version = ( (IVMInstall2) fVMInstance ).getJavaVersion( );
	}
	else
	{
		LibraryInfo libInfo = LaunchingPlugin.getLibraryInfo( fVMInstance.getInstallLocation( )
				.getAbsolutePath( ) );
		if ( libInfo == null )
		{
			return 0D;
		}
		version = libInfo.getVersion( );
	}
	int index = version.indexOf( "." ); //$NON-NLS-1$
	int nextIndex = version.indexOf( ".", index + 1 ); //$NON-NLS-1$
	try
	{
		if ( index > 0 && nextIndex > index )
		{
			return Double.parseDouble( version.substring( 0, nextIndex ) );
		}
		return Double.parseDouble( version );
	}
	catch ( NumberFormatException e )
	{
		return 0D;
	}

}
 
开发者ID:eclipse,项目名称:birt,代码行数:39,代码来源:StandardScriptVMRunner.java


注:本文中的org.eclipse.jdt.launching.IVMInstall2类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。