title: How to load a class from annotations processor in eclipse?
body: <p>I implemented an Annotation Processor and I'm trying to load a class that is referenced by some nested element of the current file being processed, for example the return type of a method.</p>
  
  <p>When I run this code from command line with javac and passing the current project classpath it successfully runs, but when using eclipse I'm getting a ClassNotFoundException. See the example below:</p>
  
  <pre><code>public class MyAnnotationProcessor extends AbstractProcessor {
  
  @Override
  public boolean process(Set&lt;? extends TypeElement&gt; annotations, RoundEnvironment roundEnv) {
  
      for (TypeElement element : annotations) {
          try {
              TypeElement type = getMethodReturnType(element);
              Class&lt;?&gt; class1 = Class.forName(type.getQualifiedName().toString());
              // ..
              // do some processing with class1
              // ...
  
          } catch (ClassNotFoundException e) {
              e.printStackTrace();
          }
      }
      return false;
  }
  </code></pre>
  
  <p>I found that in eclipse the processor doesn't have the classpath of the current project. I could create an URLClassLoader to load those required classes but can't find a way to get the current project path.</p>
  
  <p>Is there a way to get the project path from the annotation processor?</p>