Even Though google shows 995,000 pages containg the text “Path for project must have only one segment” – None of them really explains what this error mean – Except if you 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 avialable or you might have forget to instantiate the IProject object or try to instantiate the IProject with different name.
Solution: Have a look at your code where you are calling
getProject.Check names, paths are called correctly.
| Progress | | copy code | | ? |
| 01 | public IProject getProject(bold;">STRING JavaDoc NAME) { |
| 02 | //bold;">FIRST check our project CACHE |
| 03 | Project result = (Project) projectTable.get(NAME); |
| 04 | bold;">IF (result == null) { |
| 05 | IPath projectPath = NEW Path(null, NAME).makeAbsolute(); |
| 06 | bold;">STRING JavaDoc bold;">MESSAGE = "Path for project must have only one segment."; //$NON-NLS-1$ |
| 07 | Assert.isLegal(projectPath.segmentCount() == ICoreConstants.PROJECT_SEGMENT_LENGTH, bold;">MESSAGE); |
| 08 | //try bold;">TO bold;">GET the project bold;">USING a canonical NAME |
| 09 | bold;">STRING JavaDoc canonicalName = projectPath.lastSegment(); |
| 10 | result = (Project) projectTable.get(canonicalName); |
| 11 | bold;">IF (result != null) |
| 12 | RETURN result; |
| 13 | result = NEW Project(projectPath, workspace); |
| 14 | projectTable.put(canonicalName, result); |
| 15 | } |
| 16 | RETURN result; |
| 17 | } |
| 18 | |
| 19 | |
| 20 |
Read more: "Java > Open Source Codes > org > eclipse > core > internal > resources > WorkspaceRoot _ Java API By Example, From Geeks To Geeks." - http://kickjava.com/src/org/eclipse/core/internal/resources/WorkspaceRoot.java.htm#ixzz0H1TWbu8u&A