The steps needed to do this are :
1. Create a source folder under the java project created earlier .
IFolder src = javaProject.getFolder("src");
folder.create(force , local , nullProgressMonitor);
IPackageFragmentRoot packageRoot = javaProject.getPackageFragmentRoot(folder);
IClasspathEntry[] classPath = javaProject.getRawClasspath();
List
entries.add(JavaCore.newSourceEntry(root.getPath()));
javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[0]) , null ProgressMonitor);
The code becomes pretty clear if you had followed my previous post.
2. Create the actual package .
src.createPackageFragment(packageName, force , nullProgressMonitor);
Yeah thats done , in the next post well see how to create a class programatically
No comments:
Post a Comment