java导入java_用Java导入Java项目到Eclipse

/**

* Imports the given path into the workspace as a project. Returns true if the

* operation succeeded, false if it failed to import due to an overlap.

*

* @param projectPath

* @return

* @throws CoreException if operation fails catastrophically

*/

private boolean importExisitingProject(IPath projectPath) throws CoreException {

// Load the project description file

final IProjectDescription description = workspace.loadProjectDescription(

projectPath.append(IPath.SEPARATOR + IProjectDescription.DESCRIPTION_FILE_NAME));

final IProject project = workspace.getRoot().getProject(description.getName());

// Only import the project if it doesn't appear to already exist. If it looks like it

// exists, tell the user about it.

if (project.exists()) {

System.err.println(SKTBuildPlugin.getFormattedMessage(

"Build.commandLine.projectExists", //$NON-NLS-1$

project.getName()));

return false;

}

IWorkspaceRunnable runnable = new IWorkspaceRunnable() {

public void run(IProgressMonitor monitor) throws CoreException {

project.create(description, monitor);

project.open(IResource.NONE, monitor);

}

};

workspace.run(runnable,

workspace.getRuleFactory().modifyRule(workspace.getRoot()),

IResource.NONE, null);

return true;

}

this thread

,您还可以导入压缩的项目,其中一些代码的灵感主要来自

org.eclipse.ui.internal.wizards.datatransfer.WizardProjectsImportPage.java

.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值