Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-core-dev] JDT- "PROJECT DOESN'T EXIST" - ERROR

Hello Everybody,
 
  I am sorry if here is the wrong place to post this question. I need your
help please.

 I have a class and after i run it as "Eclpse Application", i receive a new
instance of the eclipse workbench(as expected) but i get errors that the
project i want to access from the class and do something with its contents
doesn't exist.I have 8 projects in my workspace, and i have tried each one
separately but i get the same error that they don't exist. This is how it
happens. When i try to open the view, i get an error:

 "
java.lang.NullPointerException
	at yukplugins.Testing.findProject(Testing.java:63)
	at yukplugins.Testing.createPartControl(Testing.java:77)
              ....
              ....
"
The 63 in the error is the source code line which produces the error:
ICompilationUnit lwCompilationUnit = lwType.getCompilationUnit();

The 77 is the following statement:
ICompilationUnit icomp = this.findProject();

Afterwards, i get an error in my console that the project am trying to
access does not exist. So it means that the program cannot find the project
that is why i get the above errors.

This is the class:
public class Testing extends ViewPart{
	 

         public void createPartControl(Composite parent){
		
		GridLayout gridLayout = new GridLayout();
		parent.setLayout(gridLayout);
		Label label = new Label(parent, SWT.CENTER);
		
		ICompilationUnit icomp = this.findProject();
		CompilationUnit comp = this.parse(icomp);

		SimpleName sn = ((TypeDeclaration)comp.types().get(0)).getName();
	             label.setText(sn.getFullyQualifiedName());

	}
	
    public void setFocus(){
		
	}


	protected CompilationUnit parse(ICompilationUnit unit) {
		ASTParser parser = ASTParser.newParser(AST.JLS3); 
		parser.setKind(ASTParser.K_COMPILATION_UNIT);
		parser.setSource(unit); // set source
		parser.setResolveBindings(true); // we need bindings later on
		return (CompilationUnit)parser.createAST(null /* IProgressMonitor */); //
parse
	}
	
	public ICompilationUnit findProject(){
		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
		//"talkJavaProject" is the project name
		IProject project = root.getProject("talkJavaProject");
		if (project.exists() && !project.isOpen())
		try {
			project.open(null /* IProgressMonitor */);
		} catch (CoreException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
				
		IJavaProject javaProject = JavaCore.create(project);
		IType lwType = null;
		try {        
                                          //"Person" is a class in the
package "files"
			lwType = javaProject.findType("files");
		} catch (JavaModelException e) {
			e.printStackTrace();
		}
		ICompilationUnit lwCompilationUnit = lwType.getCompilationUnit();
		return lwCompilationUnit;
	}

}


This is the error i receive in my console:


Java Model Exception: Java Model Status [talkJavaProject does not exist]
	at
org.eclipse.jdt.internal.core.JavaElement.newNotPresentException(JavaElement.java:485)
	at
org.eclipse.jdt.internal.core.JavaProject.buildStructure(JavaProject.java:391)
	at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:229)
	at
org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:505)
	at
org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:249)
	at
org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:235)
	at
org.eclipse.jdt.internal.core.JavaProject.getJavaProjectElementInfo(JavaProject.java:1529)
	at
org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.java:2201)
	at
org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.java:2211)
	at
org.eclipse.jdt.internal.core.JavaProject.findType(JavaProject.java:1263)
	at
org.eclipse.jdt.internal.core.JavaProject.findType(JavaProject.java:1170)
	at yukplugins.Testing.findProject(Testing.java:58)
	at yukplugins.Testing.createPartControl(Testing.java:77)
	at
org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:370)
	at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:227)
	at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:592)
	at org.eclipse.ui.internal.Perspective.showView(Perspective.java:2086)
	at
org.eclipse.ui.internal.WorkbenchPage.busyShowView(WorkbenchPage.java:1027)
	at org.eclipse.ui.internal.WorkbenchPage.access$19(WorkbenchPage.java:1008)
	at org.eclipse.ui.internal.WorkbenchPage$19.run(WorkbenchPage.java:3684)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
             ...
             ...
            at org.eclipse.equinox.launcher.Main.main(Main.java:1148)

            I would like someone to help me to find why the program cannot
find the project. Maybe i am accessing it in the wrong way. I need help. 

Thank you all.

Regards,
Eddy
-- 
View this message in context: http://www.nabble.com/JDT---%22PROJECT-DOESN%27T-EXIST%22----ERROR-tp23191589p23191589.html
Sent from the Eclipse JDT - core mailing list archive at Nabble.com.



Back to the top