Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsIProgressMonitor missing
https://www.eclipse.org/forums/index.php/mv/msg/1091553/1781408/#msg_1781408
I'm using Eclipse Oxygen 2 and trying to parse Java source code using the ASTParser. (I added all the JDTSource-4.7.2 jars.) However, when I try to create the AST I get this:
- The type org.eclipse.core.runtime.IProgressMonitor cannot be resolved. It is indirectly referenced from required .class files
- The method createAST(IProgressMonitor) from the type ASTParser refers to the missing type IProgressMonitor.
Other people had the same problem and said that if I add the org.eclipse.equinox.common jar, this error will disappear and indeed it did. However when I run the program, I get this: Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/resources/IResource
The code is below (it's not mine, I got it from programcreek):
final CompilationUnit cu = (CompilationUnit)parser.createAST(null);
ASTVisitor visitor = new ASTVisitor() {
Set nodeNames = new HashSet();
public boolean visit(VariableDeclarationFragment node) {
SimpleName nodeName = node.getName();
this.nodeNames.add(nodeName.getIdentifier());
System.out.println("Declaration of '"+nodeName+"' at line"+cu.getLineNumber(nodeName.getStartPosition()));
return false;
}
};
cu.accept(visitor);
}
public static void main (String[] args) {
String file = readFile("src/Person.java");
parse(file);
}
}
]]>Laura Lala2018-02-06T22:59:23-00:00Re: IProgressMonitor missing
https://www.eclipse.org/forums/index.php/mv/msg/1091553/1781416/#msg_1781416
Note that even is you are developing a stand alone application it is still much easier (in my opinion) to convert the project to a Plug-in project so that the classpath is managed for you via dependencies specified in the MANIFEST.MF. Then you don't need to put anything specific on the classpath; the dependencies are automatically on the classpath via PDE's plugin container classpath entry; the even works for a Java Application launch.]]>Ed Merks2018-02-07T06:57:58-00:00