How can I import eclipse JDT classes in a project

user5915 picture user5915 · Sep 18, 2008 · Viewed 10.2k times · Source

I want to do the following imports in a class.

import org.eclipse.jdt.core.dom.*;  
import org.eclipse.jdt.core.compiler.CharOperation;  
import org.eclipse.jdt.core.compiler.IProblem;  
import org.eclipse.jdt.internal.compiler.ClassFile;  
import org.eclipse.jdt.internal.compiler.CompilationResult;  
import org.eclipse.jdt.internal.compiler.Compiler;    
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;  
import org.eclipse.jdt.internal.compiler.ICompilerRequestor;  
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;  
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;  
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;  
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;  
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;  
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;  
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;  
import org.eclipse.jface.text.Document;  
import org.eclipse.jface.text.BadLocationException;  
import org.eclipse.text.edits.TextEdit;  

How can I import the JDT within Eclipse? Cheers.

Answer

delfuego picture delfuego · Sep 18, 2008

I think I found an easier way to do this:

  • right-click on your project in the Package Explorer;
  • choose "Build Path...";
  • choose "Configure Build Path";
  • choose the Libraries tab;
  • click the "Add Variable..." button;
  • in the list box, choose the "ECLIPSE_HOME" entry, and then click the "Extend" button;
  • in the list box, open up the "plugins" folder entry, scroll way down, and shift-click all the org.eclipse.jdt.* JAR files that are in the file listing beneath the folders;
  • click OK until you're all the way back out.

That should do it.