I’m new to eclipse plugin development, and I inherited some Eclipse plugin code and I’m trying to figure out how to do something relatively simple.
In a nutshell, you right-click on a Java class in your project, the wizard opens and the fully qualified classname of the selected Java class appears in a text field. When you click “next”, the code attempts to do a CClass.forName(s) where s is the class name.
The problem is, the Class.forName throws a class not found exception, I assume because the Java class in the eclipse project is not actually in the classpath of the wizard.
Can anyone point me in the right direction? How do I ensure the classes in the eclipse project are visible to the wizard, classpath-wise?
You cannot use Class.forName() for this. The java class in a Java project that your plugin operates on is not even in the same process as your plugin, let alone available for loading to any classloader.
You should be looking at JDT’s Java Model or Java AST API to make a plugin that operates on Java files in a Java project.
http://www.vogella.de/articles/EclipseJDT/article.html