Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [pde-dev] Cannot load classes when running a plug-in

Hi Hadas,
first of all, the best place for users questions are newsgroups (www.eclipse.org/newsgroups). The best one for your question should be platform.jdt newsgroup.
This mailing list is for PDE developers team.

Class.forName() uses classloader to search for classes within a started application (in your case Eclipse), so it doesn't know anything about Java files in any user directories (e.g. workspace). For example in Eclipse when you click "Run As -> JUnit Test" on your JUnit test, Eclipse actually starts a new application (located in plug-in org.eclipse.jdt.junit.runtime), adds to it's classpath all the directories containing user's JUnit tests (so the JUnit tests will be accessible thru Class.forName()) and collects the testing results to display them later in JUnit view.

shadass pisze:
Hello, everybody.
I'm a student and new in eclipse and I have a problem that I'm dealing with
for more then a week but haven't resolved yet:
I'm developing a plugin(in java) - an expension to the eclipse IDE - that
one of its features is running a unit test and generate a report of its
results.
I've added a button that let the user to choose the wanted file and to run
it with JUnit.core.run.
When I run the plugin as eclipse application the fileChooser returns the
file full path.
JUnit.core.run suppose to get a Class, so I use Class.forName() to load the
class (I generate a class name from the full path). The problem is that Class.forName() is looking for the class in the wrong
workspace. It looks for the class in my workspace (the plugin development
workspace) and no in the user's workspace (run time workspace) and it throws
an exception: class not found. When I choose a unit test from my workspace, it run it with no exception.
In addition to the problem that it doesn't find the class, the unit test
must run in its own workspace because it uses the classes of the current
project.
I don't know what to do.
I'll be happy to get some ideas.
Thanks Hadas





Back to the top