John Smith
John Smith

Reputation: 787

Project name under workspace Eclipse

I need to store the project names under a workspace into a list. I'm searching for a predefined function that returns all the project names in the workspace. Is in Eclipse such a function ? (plugin project)

Thank you !

Upvotes: 0

Views: 207

Answers (1)

greg-449
greg-449

Reputation: 111142

This will get the names in a list:

IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

IProject [] projects = root.getProjects();

List<String> names = new ArrayList<>();

for (IProject project : projects) {
   names.add(project.getName());
}

This code must be run in a Eclipse plugin or headless app.

Upvotes: 1

Related Questions