本文整理汇总了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);
}
}
}
示例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;
}
示例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();
}
}
示例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);
}
示例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()]);
}
示例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;
}
}
}
示例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 );
}
}
示例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;
}
示例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();
}
示例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()]);
}
示例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);
}
示例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;
}
示例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;
}
示例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[] {};
}