當前位置: 首頁>>代碼示例>>Java>>正文


Java JavaRuntime.getDefaultVMInstall方法代碼示例

本文整理匯總了Java中org.eclipse.jdt.launching.JavaRuntime.getDefaultVMInstall方法的典型用法代碼示例。如果您正苦於以下問題:Java JavaRuntime.getDefaultVMInstall方法的具體用法?Java JavaRuntime.getDefaultVMInstall怎麽用?Java JavaRuntime.getDefaultVMInstall使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jdt.launching.JavaRuntime的用法示例。


在下文中一共展示了JavaRuntime.getDefaultVMInstall方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getVMInstall

import org.eclipse.jdt.launching.JavaRuntime; //導入方法依賴的package包/類
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();
}
 
開發者ID:tlaplus,項目名稱:tlaplus,代碼行數:19,代碼來源:AbstractJob.java

示例2: getVMInstall

import org.eclipse.jdt.launching.JavaRuntime; //導入方法依賴的package包/類
public IVMInstall getVMInstall() {
	if (getVMInstallTypeId() == null)
		return JavaRuntime.getDefaultVMInstall();
	try {
		IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(getVMInstallTypeId());
		IVMInstall[] vmInstalls = vmInstallType.getVMInstalls();
		int size = vmInstalls.length;
		String id = getVMInstallId();
		for (int i = 0; i < size; i++) {
			if (id.equals(vmInstalls[i].getId()))
				return vmInstalls[i];
		}
	}
	catch (Exception e) {
		// ignore
	}
	return null;
}
 
開發者ID:eclipse,項目名稱:cft,代碼行數:19,代碼來源:CloudFoundryServerRuntime.java

示例3: reformatJavaFiles

import org.eclipse.jdt.launching.JavaRuntime; //導入方法依賴的package包/類
/**
 * Recursively find the .java files in the output directory and reformat them.
 *
 * @throws CoreException
 */
private static void reformatJavaFiles(File outDir) throws CoreException {
  // If a default JRE has not yet been detected (e.g. brand new workspace),
  // the compiler source compliance may be set to 1.3 (the default value from
  // code). This is a problem because the generated files do not compile
  // against 1.3 (e.g. they use annotations), and thus the formatting will not
  // succeed. We work around this using a trick from the
  // CompliancePreferencePage: Ensure there is a default JRE which in
  // turn updates the compliance level.
  JavaRuntime.getDefaultVMInstall();

  List<File> javaFiles = ProjectResources.findFilesInDir(outDir, javaSourceFilter);

  for (File file : javaFiles) {
    ProjectResources.reformatJavaSource(file);
  }
}
 
開發者ID:gwt-plugins,項目名稱:gwt-eclipse-plugin,代碼行數:22,代碼來源:WebAppProjectCreator.java

示例4: getDefaultEEName

import org.eclipse.jdt.launching.JavaRuntime; //導入方法依賴的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: addClassPathEntries

import org.eclipse.jdt.launching.JavaRuntime; //導入方法依賴的package包/類
public void addClassPathEntries() {
  try {
    final ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
    final IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
    LibraryLocation[] _libraryLocations = JavaRuntime.getLibraryLocations(vmInstall);
    final Consumer<LibraryLocation> _function = new Consumer<LibraryLocation>() {
      @Override
      public void accept(final LibraryLocation eachLocation) {
        IPath _systemLibraryPath = eachLocation.getSystemLibraryPath();
        IClasspathEntry _newLibraryEntry = JavaCore.newLibraryEntry(_systemLibraryPath, null, null);
        entries.add(_newLibraryEntry);
      }
    };
    ((List<LibraryLocation>)Conversions.doWrapArray(_libraryLocations)).forEach(_function);
    int _size = entries.size();
    IClasspathEntry[] _newArrayOfSize = new IClasspathEntry[_size];
    IClasspathEntry[] _array = entries.<IClasspathEntry>toArray(_newArrayOfSize);
    this.javaProject.setRawClasspath(_array, null);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
開發者ID:SENSIDL-PROJECT,項目名稱:SensIDL,代碼行數:23,代碼來源:MavenProjectGenerator2.java

示例6: is50OrHigherJRE

import org.eclipse.jdt.launching.JavaRuntime; //導入方法依賴的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

示例7: createRuntime

import org.eclipse.jdt.launching.JavaRuntime; //導入方法依賴的package包/類
private static IRuntime createRuntime(String runtimeName, String location,
		IProgressMonitor progressMonitor) throws CoreException {
	IRuntimeWorkingCopy runtime = null;
	String type = null;
	String version = null;
	String runtimeId = null;
	org.eclipse.core.runtime.IPath jbossAsLocationPath = new Path(location);
	IRuntimeType runtimeTypes[] = ServerUtil.getRuntimeTypes(type, version,
			"org.eclipse.jst.server.tomcat.runtime.60");
	if (runtimeTypes.length > 0) {
		runtime = runtimeTypes[0].createRuntime(runtimeId, progressMonitor);
		runtime.setLocation(jbossAsLocationPath);
		if (runtimeName != null)
			runtime.setName(runtimeName);
		IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall();
		((RuntimeWorkingCopy) runtime).setAttribute("PROPERTY_VM_ID",
				defaultVM.getId());
		((RuntimeWorkingCopy) runtime).setAttribute("PROPERTY_VM_TYPE_ID",
				defaultVM.getVMInstallType().getId());
		return runtime.save(false, progressMonitor);
	} else {
		return runtime;
	}
}
 
開發者ID:winture,項目名稱:wt-studio,代碼行數:25,代碼來源:TomcatStartup.java

示例8: createProject

import org.eclipse.jdt.launching.JavaRuntime; //導入方法依賴的package包/類
/**
 * This method creates a new java project based on the user inputs, captured in WizardInput object.
 * The new project is created in the current workspace.
 * @param wizardInput
 * @return IJavaProject
 * @throws CoreException
 * @throws IOException
 **/
public IJavaProject createProject(WizardInput wizardInput) throws CoreException, IOException
{
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IProject project = root.getProject(wizardInput.getProjectName());
	project.create(null);
	project.open(null);		
	IProjectDescription description = project.getDescription();
	description.setNatureIds(new String[] { JavaCore.NATURE_ID });
	project.setDescription(description, null);
	IJavaProject javaProject = JavaCore.create(project); 
	IFolder binFolder = project.getFolder("bin");
	binFolder.create(false, true, null);
	javaProject.setOutputLocation(binFolder.getFullPath(), null);
	List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
	IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
	LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);
	for (LibraryLocation element : locations) {
	 entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null));
	}
	InputStream is = new BufferedInputStream(new FileInputStream(wizardInput.getSootPath().toOSString()));
    IFile jarFile = project.getFile("soot-trunk.jar");
    jarFile.create(is, false, null);
    IPath path = jarFile.getFullPath();
    entries.add(JavaCore.newLibraryEntry(path, null, null));
	javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);		
	IFolder sourceFolder = project.getFolder("src");
	sourceFolder.create(false, true, null);
	IPackageFragmentRoot root1 = javaProject.getPackageFragmentRoot(sourceFolder);
	IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
	IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];
	System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);
	newEntries[oldEntries.length] = JavaCore.newSourceEntry(root1.getPath());
	javaProject.setRawClasspath(newEntries, null);
	String filepath = sourceFolder.getLocation().toOSString();
	File file = new File(filepath);
	wizardInput.setFile(file);
	try {
		CodeGenerator.generateSource(wizardInput);
	} catch (JClassAlreadyExistsException e) {
		e.printStackTrace();
	}
	sourceFolder.refreshLocal(1, null);
	javaProject.open(null);
	return javaProject;
}
 
開發者ID:VisuFlow,項目名稱:visuflow-plugin,代碼行數:54,代碼來源:ProjectGenerator.java

示例9: start

import org.eclipse.jdt.launching.JavaRuntime; //導入方法依賴的package包/類
@Override
public void start(BundleContext context) throws Exception {
  super.start(context);
  plugin = this;
  // Initalizes the compliance options to include the default VM's compliance level.
  JavaRuntime.getDefaultVMInstall();
}
 
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-eclipse,代碼行數:8,代碼來源:DataflowCorePlugin.java

示例10: getVMInstall

import org.eclipse.jdt.launching.JavaRuntime; //導入方法依賴的package包/類
/**
 * 
 * @return
 */
public IVMInstall getVMInstall() {
    final IVMInstallType[] vmTypes = JavaRuntime.getVMInstallTypes();
    for (final IVMInstallType vmType : vmTypes) {
        final IVMInstall[] vms = vmType.getVMInstalls();
        for (final IVMInstall vm : vms) {
            if (vm.getId().equals(WeblogicPlugin.getDefault().getJRE())) {
                return vm;
            }
        }
    }
    return JavaRuntime.getDefaultVMInstall();
}
 
開發者ID:rajendarreddyj,項目名稱:eclipse-weblogic-plugin,代碼行數:17,代碼來源:WeblogicLauncher.java

示例11: configureVM

import org.eclipse.jdt.launching.JavaRuntime; //導入方法依賴的package包/類
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;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:31,代碼來源:JDTLanguageServer.java

示例12: testDefaultVM

import org.eclipse.jdt.launching.JavaRuntime; //導入方法依賴的package包/類
@Test
public void testDefaultVM() throws CoreException {
	String oldJavaHome = prefManager.getPreferences().getJavaHome();
	IVMInstall oldVm = JavaRuntime.getDefaultVMInstall();
	assertNotNull(oldVm);
	try {
		IVMInstall vm = null;
		IVMInstallType type = JavaRuntime.getVMInstallType(TestVMType.VMTYPE_ID);
		IVMInstall[] installs = type.getVMInstalls();
		for (IVMInstall install : installs) {
			if (!install.equals(oldVm)) {
				vm = install;
				break;
			}
		}
		assertNotNull(vm);
		assertNotEquals(vm, oldVm);
		String javaHome = new File(TestVMType.getFakeJDKsLocation(), "9").getAbsolutePath();
		prefManager.getPreferences().setJavaHome(javaHome);
		boolean changed = server.configureVM();
		IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall();
		assertTrue("A VM hasn't been changed", changed);
		assertEquals(vm, defaultVM);
		assertNotEquals(oldVm, defaultVM);
	} finally {
		prefManager.getPreferences().setJavaHome(oldJavaHome);
		TestVMType.setTestJREAsDefault();
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:30,代碼來源:JDTLanguageServerTest.java

示例13: isRuntimeJar

import org.eclipse.jdt.launching.JavaRuntime; //導入方法依賴的package包/類
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;
}
 
開發者ID:JReFrameworker,項目名稱:JReFrameworker,代碼行數:12,代碼來源:RuntimeUtils.java

示例14: getRuntimeJar

import org.eclipse.jdt.launching.JavaRuntime; //導入方法依賴的package包/類
public static File getRuntimeJar(String jarName) 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.getName().equals(jarName)){
			return runtime;
		}
	}
	return null;
}
 
開發者ID:JReFrameworker,項目名稱:JReFrameworker,代碼行數:12,代碼來源:RuntimeUtils.java

示例15: setDefaultCompilerComplianceValues

import org.eclipse.jdt.launching.JavaRuntime; //導入方法依賴的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-Juno38,代碼行數:20,代碼來源:ComplianceConfigurationBlock.java


注:本文中的org.eclipse.jdt.launching.JavaRuntime.getDefaultVMInstall方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。