views:

22

answers:

1

I am trying to programmatically access the src/ directory in an Eclipse project (type IProject).

Basically, my problem is as follows:

  • INPUT: IProject
  • OUTPUT: Return the src directory in this IProject
  • Notes: The src directory may be called anything else (it need not be "src" every time -- it is decided when creating the java project)

Any pointers on how I can do this?

+1  A: 
  1. Cast the IProject to IJavaProject.
  2. Get the array of IPackageFragmentRoot using getAllPackageFragmentRoots()
  3. Get the one(s) which have getKind() == IPackageFragmentRoot.K_SOURCE
nanda
Perfect. Thank you so much.
Nocturne