Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Using the Eclipse Abtract Syntax Tree not as a plugin
Using the Eclipse Abtract Syntax Tree not as a plugin [message #503603] Mon, 14 December 2009 17:01 Go to next message
Eclipse UserFriend
I'm trying to use AST parser in a non-plugin environment. The code compiles, but I get the following runtime error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/resources/IResource
at org.eclipse.jdt.core.dom.ASTParser.<init>(ASTParser.java:189)
at org.eclipse.jdt.core.dom.ASTParser.newParser(ASTParser.java: 118)

Here is the code I'm running:
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.dom.*;

public class AST
{
	
	private void runTest()
	{
		String helloStr ="\n"+
		"public class HelloWorld {\n"+
		"\n"+
		"	private String name=\"\"\n\n"+
		"	/**\n"+
		"	 * \n"+
		"	 */\n"+
		"	 public void sayHello() {\n"+
		"	 System.out.println(\"Hello \"+name+\"!\");\n"+
		"	 }\n"+
		"\n"+
		"}";
		
		ASTParser parser = ASTParser.newParser(org.eclipse.jdt.core.dom.AST.JLS3); 
		parser.setKind(ASTParser.K_COMPILATION_UNIT);
		parser.setSource(helloStr.toCharArray());
		parser.setResolveBindings(true);
		ASTNode tree = parser.createAST(null);
		tree.toString();
		
	}
		
	public static void main(String args[])
	{
		AST ast = new AST();
		ast.runTest();
	}
}


Does anyone know why this is happening?

Thanks in advance,

Shirley

Re: Using the Eclipse Abtract Syntax Tree not as a plugin [message #503613 is a reply to message #503603] Mon, 14 December 2009 18:46 Go to previous message
Eclipse UserFriend
Le 2009-12-14 17:01, Shirley Cohen a écrit :
> I'm trying to use AST parser in a non-plugin environment. The code
> compiles, but I get the following runtime error:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/eclipse/core/resources/IResource
> at org.eclipse.jdt.core.dom.ASTParser.<init>(ASTParser.java:189)
> at org.eclipse.jdt.core.dom.ASTParser.newParser(ASTParser.java: 118
Even if the DOM/AST API can work in a non-plugin environment, you still
need a bunch of jars on the classpath.
resources, runtime, and maybe others.

The best way to find out is to select org.eclipse.jdt.core in the
plugins tab inside an Eclipse launching configuration and select
required bundles.
You should get the complete list of required jars on the classpath.
--
Olivier
Previous Topic:plugin needed: c-style precompiler for java
Next Topic:[ASK] J2ME cannot create jar
Goto Forum:
  


Current Time: Wed Mar 19 23:08:49 EDT 2025

Powered by FUDForum. Page generated in 0.04571 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top