I am trying to programmatically access the src/ directory in an Eclipse project (type IProject).
Basically, my problem is as follows:
Any pointers on how I can do this?
src is where Java IDEs (at least Eclipse and NetBeans) put the source files, it is pretty much standard, and the hierarchy of the folder inside it has to match your Java packages names.
Files will be referenced relative to your project path, so use "resources/file. txt" to reference the file. However, if you want the file to be accessible when you export the program as a JAR, the path "resources/file. txt" must exist relative to your JAR.
IProject
to IJavaProject
.IPackageFragmentRoot
using getAllPackageFragmentRoots()
getKind() == IPackageFragmentRoot.K_SOURCE
The last answer did not work for me for the point number one, but following did:
IProject project = ...
if (project.isOpen() && JavaProject.hasJavaNature(project))
{
IJavaProject javaProject = JavaCore.create(project);
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With