I am trying to use Eclipse's AST parser as a standalone to parse Java source files. This is a small snippet of a code to get the compilation unit:
public CompilationUnit getCompilationUnit(ASTParser parser) {
parser.setResolveBindings(true);
CompilationUnit cu = (CompilationUnit) parser.createAST(null);
return cu;
}
If I try to execute this code standalone ie without Eclipse IDE, I am getting below error:
java.lang.NoSuchFieldError: resources
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2545) [org.eclipse.jdt.core_3.8.2.v20120814-155456.jar:]
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2423) [org.eclipse.jdt.core_3.8.2.v20120814-155456.jar:]
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:534) [org.eclipse.jdt.core_3.8.2.v20120814-155456.jar:]
I am not understanding from where does it's calling method `resources`. If I try to run from Eclipse IDE it works without any issues. I have included following JAR files in the classpath:
org.eclipse.core.contenttype_3.4.200.v20120523-2004.jar
org.eclipse.core.jobs_3.5.300.v20120912-155018.jar
org.eclipse.core.resources_3.8.1.v20121114-124432.jar
org.eclipse.core.runtime_3.8.0.v20120912-155025.jar
org.eclipse.equinox.common_3.6.100.v20120522-1841.jar
org.eclipse.equinox.preferences_3.5.1.v20121031-182809.jar
org.eclipse.jdt.core_3.8.3.v20130121-145325.jar
org.eclipse.osgi_3.8.2.v20130124-134944.jar
I have included all of the necessary jar files to run successfully. But when I run this error occurs. Can anyone please guide me?