|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
JDT- "PROJECT DOESN'T EXIST" - ERRORHello 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(); You can find the above statement in the "findProject()" method The 77 is the following statement: ICompilationUnit icomp = this.findProject(); You can find the above statement in the "createPartControl(Composite parent)" method 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 or i have to add additional things to it. I need help. Thank you all. Regards, Eddy |
|
|
RE: JDT- "PROJECT DOESN'T EXIST" - ERROREddy, as previously mentioned, the right place to ask the question is in
the eclipse.tools.jdt newsgroup. The jdt-core-dev mailing list is for the developers of the JDT. It is not a support line. When you post here, you are reducing the number of people who can read and respond to your question, and the answers will help fewer people. Also you are basically asking everyone on JDT to stop whatever they are working on and help you instead. Please post your question to eclipse.tools.jdt, and people will help you when and if they are able. Thanks! > -----Original Message----- > > Hello Everybody, > > I am sorry if here is the wrong place to post this > question. I need your help please. _______________________________________________ jdt-core-dev mailing list jdt-core-dev@... https://dev.eclipse.org/mailman/listinfo/jdt-core-dev |
| Free embeddable forum powered by Nabble | Forum Help |