//直接上代码
IProjectDescription description = project.getDescription();
String[] prevNatures= description.getNatureIds();
String[] newNatures= new String[prevNatures.length + 1];
System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
newNatures[prevNatures.length]= JavaCore.NATURE_ID;//代表Java Nature
description.setNatureIds(newNatures);
project.setDescription(description, monitor);
本文介绍了一种在Java项目中通过编程方式添加JavaNature的方法。具体步骤包括获取项目的描述信息,复制并追加新的NatureID,最后更新项目描述。
1027

被折叠的 条评论
为什么被折叠?



