Eclipse Error: Path for project must have only one segment

Have a look at the source code of WorkspaceRoot class, particularly ‘getProject’ method:

This problem usually occurs when you try to access a project name/path,etc, when it is not available or you might have forget to instantiate the IProject object or try to instantiate the IProject with different name. Have a look at your code where you are calling getProject. Check names, paths are called correctly.