2

When trying to use an AST in a java project in eclipse, I get this error message is runtime: Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IAdaptable

I've tried adding to the build path the core.runtime jar, but that didn't help.

The code fails right on the beginning:

AST ast = AST.newAST(AST.JLS4);

I also tried adding all the jars in my computer but to no avail. any ideas?

stack trace:

Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IAdaptable
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at testRun.main(testRun.java:44)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.IAdaptable
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 25 more
4
  • Did you make an executable jar? Commented Dec 21, 2012 at 15:58
  • 1
    It would help if you posted your stack trace Commented Dec 21, 2012 at 15:58
  • No Jar, running by pressing 'play' on eclipse. Commented Dec 21, 2012 at 16:09
  • Have you done anything to adjust the Target Platform? What's the text of the button where you pressed 'play'? Are you developing a plug-in or a Java Application? Give more specifics. Commented Dec 21, 2012 at 21:11

1 Answer 1

4

Besides adding org.eclipse.jdt.core_[version_number].jar to your Build Path, you also need to add org.eclipse.equinox.common_[version_number].jar.

Sign up to request clarification or add additional context in comments.

3 Comments

@Templar because class org.eclipse.core.runtime.IAdaptable is defined in package org.eclipse.equinox.common
@Sean I have both of these jars (org.eclipse.equinox.common-3.6.0.v20100503 and org.eclipse.jdt.core-3.7.0.v_B61), but am still getting the same exception. Does the version number need to be the same for both jars? I also have org.eclipse.core.runtime-3.1.0.jar which has IAdaptable class as well. Even when I remove this jar, it still gives the same error. Any ideas?
@ShreyansPagariya I think you should use the compatable version(like keeping all these jars latest. search from mvnrepo); make sure these jars are added to your classpath

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.