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


Java JavaRuntime类代码示例

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


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

示例1: updateClasspath

import org.eclipse.jdt.launching.JavaRuntime; //导入依赖的package包/类
private boolean updateClasspath(IPath newPath, IProgressMonitor monitor) throws JavaModelException {
	boolean updated= false;
	
	IClasspathEntry[] classpath= fProject.getRawClasspath();
	IPath jreContainerPath= new Path(JavaRuntime.JRE_CONTAINER);
	for (int i= 0; i < classpath.length; i++) {
		IClasspathEntry curr= classpath[i];
		if (curr.getEntryKind() == IClasspathEntry.CPE_CONTAINER && curr.getPath().matchingFirstSegments(jreContainerPath) > 0) {
			if (! newPath.equals(curr.getPath())) {
				updated= true;
				classpath[i]= JavaCore.newContainerEntry(newPath, curr.getAccessRules(), curr.getExtraAttributes(), curr.isExported());
			}
		}
	}
	if (updated) {
		fProject.setRawClasspath(classpath, monitor);
	}
	return updated;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:20,代码来源:ReorgCorrectionsSubProcessor.java

示例2: getProjectClassPath

import org.eclipse.jdt.launching.JavaRuntime; //导入依赖的package包/类
public static void getProjectClassPath(IJavaProject project, List<File> dst) throws Exception {
	IRuntimeClasspathEntry [] rentries = JavaRuntime.computeUnresolvedRuntimeClasspath(project);
	for (IRuntimeClasspathEntry entry : rentries) {
		switch (entry.getType()) {
		case IClasspathEntry.CPE_SOURCE: 
			break;
		case IClasspathEntry.CPE_PROJECT:
			break;
		case IClasspathEntry.CPE_LIBRARY:
			break;
		case IClasspathEntry.CPE_VARIABLE:
			// JRE like entries
			IRuntimeClasspathEntry [] variableEntries  = JavaRuntime.resolveRuntimeClasspathEntry(entry, project);
			break;
		case IClasspathEntry.CPE_CONTAINER:
			IRuntimeClasspathEntry [] containerEntries  = JavaRuntime.resolveRuntimeClasspathEntry(entry, project);
			for (IRuntimeClasspathEntry containerentry : containerEntries) {
				dst.add(new File (containerentry.getLocation()));
			}
			break;
		default:
			throw new Exception("unsupported classpath entry "+entry);
		}
	}
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:26,代码来源:TestResourceGeneration.java

示例3: getProjectClassPathList

import org.eclipse.jdt.launching.JavaRuntime; //导入依赖的package包/类
/**
 * @return
 */
public static List<String> getProjectClassPathList() {
    final String projects = getProjects();
    final List<String> projectList = toArrayList(projects, PATH_SEPARATOR);
    final List<String> projectClassPathList = new ArrayList<>();
    final Iterator<String> iterator = projectList.iterator();
    while (iterator.hasNext()) {
        final String projectName = iterator.next();
        final IProject iproject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
        final IJavaProject jproject = JavaCore.create(iproject);
        try {
            if ((jproject != null) && jproject.exists() && jproject.isOpen()) {
                final String[] projectcp = JavaRuntime.computeDefaultRuntimeClassPath(jproject);
                for (final String element : projectcp) {
                    projectClassPathList.add(element);
                }
            }
        } catch (final CoreException localCoreException) {
        }
    }
    return projectClassPathList;
}
 
开发者ID:rajendarreddyj,项目名称:eclipse-weblogic-plugin,代码行数:25,代码来源:WeblogicPreferenceStore.java

示例4: setAllVMs

import org.eclipse.jdt.launching.JavaRuntime; //导入依赖的package包/类
/**
 * This method will fetch and set All Available JVMs in Dropdown
 */
private void setAllVMs() {
    final List<IVMInstall> allVMs = new ArrayList<>();
    final IVMInstallType[] vmTypes = JavaRuntime.getVMInstallTypes();
    for (final IVMInstallType vmType : vmTypes) {
        final IVMInstall[] vms = vmType.getVMInstalls();
        for (final IVMInstall vm : vms) {
            allVMs.add(vm);
        }
    }
    this.jvmNamesAndValues = new String[allVMs.size()][2];
    for (int i = 0; i < allVMs.size(); i++) {
        this.jvmNamesAndValues[i][0] = allVMs.get(i).getName();
        this.jvmNamesAndValues[i][1] = allVMs.get(i).getId();
    }
}
 
开发者ID:rajendarreddyj,项目名称:eclipse-weblogic-plugin,代码行数:19,代码来源:JVMOptionsPreferencePage.java

示例5: computeUnresolvedClasspath

import org.eclipse.jdt.launching.JavaRuntime; //导入依赖的package包/类
@Override
public IRuntimeClasspathEntry[] computeUnresolvedClasspath(final ILaunchConfiguration configuration)
      throws CoreException {
    boolean useDefault = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
    if(useDefault) {
      IJavaProject javaProject = JavaRuntime.getJavaProject(configuration);
      IRuntimeClasspathEntry jreEntry = JavaRuntime.computeJREEntry(configuration);
      IRuntimeClasspathEntry projectEntry = JavaRuntime.newProjectRuntimeClasspathEntry(javaProject);
      IRuntimeClasspathEntry mavenEntry = JavaRuntime.newRuntimeContainerClasspathEntry(new Path(
          IClasspathManager.CONTAINER_ID), IRuntimeClasspathEntry.USER_CLASSES);

      if(jreEntry == null) {
        return new IRuntimeClasspathEntry[] {projectEntry, mavenEntry};
      }

      return new IRuntimeClasspathEntry[] {jreEntry, projectEntry, mavenEntry};
    }

    return recoverRuntimePath(configuration, IJavaLaunchConfigurationConstants.ATTR_CLASSPATH);
  }
 
开发者ID:fbricon,项目名称:wildfly-hive,代码行数:21,代码来源:MavenRuntimeClasspathProvider.java

示例6: resolveClasspath0

import org.eclipse.jdt.launching.JavaRuntime; //导入依赖的package包/类
IRuntimeClasspathEntry[] resolveClasspath0(IRuntimeClasspathEntry[] entries, ILaunchConfiguration configuration,
    IProgressMonitor monitor) throws CoreException {
  int scope = getArtifactScope(configuration);
  Set<IRuntimeClasspathEntry> all = new LinkedHashSet<>(entries.length);
  for(IRuntimeClasspathEntry entry : entries) {
    if(entry.getType() == IRuntimeClasspathEntry.CONTAINER
        && MavenClasspathHelpers.isMaven2ClasspathContainer(entry.getPath())) {
      addMavenClasspathEntries(all, entry, configuration, scope, monitor);
    } else if(entry.getType() == IRuntimeClasspathEntry.PROJECT) {
      IJavaProject javaProject = JavaRuntime.getJavaProject(configuration);
      if(javaProject.getPath().equals(entry.getPath())) {
        addProjectEntries(all, entry.getPath(), scope, THIS_PROJECT_CLASSIFIER, configuration, monitor);
      } else {
        addStandardClasspathEntries(all, entry, configuration);
      }
    } else {
      addStandardClasspathEntries(all, entry, configuration);
    }
  }
  return all.toArray(new IRuntimeClasspathEntry[all.size()]);
}
 
开发者ID:fbricon,项目名称:wildfly-hive,代码行数:22,代码来源:MavenRuntimeClasspathProvider.java

示例7: addMavenClasspathEntries

import org.eclipse.jdt.launching.JavaRuntime; //导入依赖的package包/类
private void addMavenClasspathEntries(Set<IRuntimeClasspathEntry> resolved,
      IRuntimeClasspathEntry runtimeClasspathEntry, ILaunchConfiguration configuration, int scope,
      IProgressMonitor monitor) throws CoreException {
    IJavaProject javaProject = JavaRuntime.getJavaProject(configuration);
    MavenJdtPlugin plugin = MavenJdtPlugin.getDefault();
    IClasspathManager buildpathManager = plugin.getBuildpathManager();
    IClasspathEntry[] cp = buildpathManager.getClasspath(javaProject.getProject(), scope, false, monitor);
    for(IClasspathEntry entry : cp) {
      switch(entry.getEntryKind()) {
        case IClasspathEntry.CPE_PROJECT:
          addProjectEntries(resolved, entry.getPath(), scope, getArtifactClassifier(entry), configuration, monitor);
          break;
        case IClasspathEntry.CPE_LIBRARY:
          resolved.add(JavaRuntime.newArchiveRuntimeClasspathEntry(entry.getPath()));
          break;
//        case IClasspathEntry.CPE_SOURCE:
//          resolved.add(newSourceClasspathEntry(javaProject, cp[i]));
//          break;
      }
    }
  }
 
开发者ID:fbricon,项目名称:wildfly-hive,代码行数:22,代码来源:MavenRuntimeClasspathProvider.java

示例8: fixRuntimeEnvironment

import org.eclipse.jdt.launching.JavaRuntime; //导入依赖的package包/类
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 );
	}
}
 
开发者ID:SAP,项目名称:hybris-commerce-eclipse-plugin,代码行数:22,代码来源:ImportPlatformWizard.java

示例9: getRemoteDebugConfig

import org.eclipse.jdt.launching.JavaRuntime; //导入依赖的package包/类
private ILaunchConfigurationWorkingCopy getRemoteDebugConfig(IProject activeProj) throws CoreException {
	ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
	ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_REMOTE_JAVA_APPLICATION);
	ILaunchConfigurationWorkingCopy config = type.newInstance(null, "Debug "+activeProj.getName());
	config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, activeProj.getName());
	config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_ALLOW_TERMINATE, true);
	config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR);
	IVMConnector connector = JavaRuntime.getVMConnector(IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR);
	Map<String, Argument> def = connector.getDefaultArguments();
	Map<String, String> argMap = new HashMap<String, String>(def.size());
	argMap.put("hostname", getHostname(activeProj));
	argMap.put("port", "8348");
	WPILibJavaPlugin.logInfo(argMap.toString());
	config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, argMap);
	return config;
}
 
开发者ID:wpilibsuite,项目名称:EclipsePlugins,代码行数:17,代码来源:JavaLaunchShortcut.java

示例10: 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

示例11: getRuntimeClasspaths

import org.eclipse.jdt.launching.JavaRuntime; //导入依赖的package包/类
protected IPath[] getRuntimeClasspaths(ILaunchConfiguration configuration)
		throws CoreException {
	IRuntimeClasspathEntry[] entries = JavaRuntime
			.computeUnresolvedRuntimeClasspath(configuration);
	entries = JavaRuntime.resolveRuntimeClasspath(entries, configuration);

	ArrayList<IPath> userEntries = new ArrayList<IPath>(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()]);
}
 
开发者ID:eclipse,项目名称:cft,代码行数:22,代码来源:JavaPackageFragmentRootHandler.java

示例12: computeSourceContainers

import org.eclipse.jdt.launching.JavaRuntime; //导入依赖的package包/类
public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor)
		throws CoreException {
	List<IRuntimeClasspathEntry> entries = new ArrayList<IRuntimeClasspathEntry>();

	IRuntimeClasspathEntry jreEntry = JavaRuntime.computeJREEntry(configuration);
	if (jreEntry != null) {
		entries.add(jreEntry);
	}

	String projectName = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
	
	if (projectName == null) {
		return null;
	}

	for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
		IJavaProject javaProject = JavaCore.create(project);
		if (javaProject != null && javaProject.isOpen() && ("".equals(projectName) || projectName.equals(javaProject.getElementName()))) { //$NON-NLS-1$
			entries.add(JavaRuntime.newDefaultProjectClasspathEntry(javaProject));
		}
	}

	IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath( //
			entries.toArray(new IRuntimeClasspathEntry[entries.size()]), configuration);
	return JavaRuntime.getSourceContainers(resolved);
}
 
开发者ID:eclipse,项目名称:cft,代码行数:27,代码来源:CloudFoundryDebugSourceLocator.java

示例13: 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

示例14: getPackageFragmentRootHandles

import org.eclipse.jdt.launching.JavaRuntime; //导入依赖的package包/类
protected List<String> getPackageFragmentRootHandles(IJavaProject project) {
	List<String> result = Lists.newArrayList();
	try {
		IPackageFragmentRoot[] roots = project.getAllPackageFragmentRoots();
		for (IPackageFragmentRoot root : roots) {
			if (root != null && !JavaRuntime.newDefaultJREContainerPath().isPrefixOf(root.getRawClasspathEntry().getPath())) {
				result.add(root.getHandleIdentifier());
			}
		}
	} catch (JavaModelException e) {
		if (!e.isDoesNotExist()) {
			log.error("Cannot find rootHandles in project " + project.getProject().getName(), e);
		}
	}
	return result;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:17,代码来源:JavaProjectsStateHelper.java

示例15: fromJavaRuntimeResolver

import org.eclipse.jdt.launching.JavaRuntime; //导入依赖的package包/类
private ISourceContainer[] fromJavaRuntimeResolver() throws CoreException {
  for (final IClasspathEntry cpe : jp.getRawClasspath()) {
    if (IClasspathEntry.CPE_CONTAINER == cpe.getEntryKind() && //
        IClasspathManager.CONTAINER_ID.equals(cpe.getPath().toString())) {
      final IRuntimeClasspathEntry newRuntimeContainerClasspathEntry = JavaRuntime.newRuntimeContainerClasspathEntry(cpe.getPath(),
          IRuntimeClasspathEntry.USER_CLASSES, jp);

      final IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry = JavaRuntime.resolveRuntimeClasspathEntry(
          newRuntimeContainerClasspathEntry, jp);

      // there is only one maven2 classpath container in a project return
      return JavaRuntime.getSourceContainers(resolveRuntimeClasspathEntry);
    }
  }

  return new ISourceContainer[] {};
}
 
开发者ID:bjmi,项目名称:m2e.sourcelookup,代码行数:18,代码来源:MyMvnSourceContainer.java


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