Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Eclipse Plugin and URLClassLoader
Eclipse Plugin and URLClassLoader [message #491112] Tue, 13 October 2009 10:39 Go to next message
StefanK  is currently offline StefanK Friend
Messages: 25
Registered: July 2009
Junior Member

I´m currently working on a eclipse plugin text editor using JFace. There is a content assist, which is accessable via ctrl+space. The content assist should give the user the option to select between various methods. The code so far:

//the path to the .class files
private static final String PATH = "C:/trunk/Parser/A4GLRuntime/bin/standardlibrary/";

public ArrayList<String> getMethodsForContentAssist() {
		if (mSizeChanged) {
			for (String lTmp : A4LStandardFunctionArrayList.getInstance()) {
				Class<?> lClass = getClassForName(lTmp);
				for (Method lMethod : lClass.getDeclaredMethods()) {
		return mList;

The singleton A4LStandardFunctionArrayList contains the classnames, every class needs to be loaded so that the methods can be extracted.

	private Class<?> getClassForName(String pName) {
		Class<?> lResult = null;
		try {
			URL[] lUrl = new URL[1];
			File lFile = new File(PATH);
			lUrl[0] = new URL(lFile.toURI().toURL().toString());
			URLClassLoader lLoader = new URLClassLoader(lUrl);
			lResult = lLoader.loadClass(pName);
		} catch (Exception Ex) {
		return lResult;

pName contains the name of the .class file, i.e. "Strings". The class "Strings.class" is available in the bin directory.

If I start the plugin and activate the content assist, the following exception is thrown:

Unhandled event loop exception

java.lang.NoClassDefFoundError: Strings (wrong name: standardlibrary/Strings)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at Source)
at Source)
at$000(Unknown Source)
at$ Source)
at Method)
at Source)

This Exception is thrown as soon as the URLClassLoader tries to load the specified class "pName", but I´m absolutely clueless why this is happening.

Thanks for the help.
Best regards

[Updated on: Tue, 13 October 2009 10:52]

Report message to a moderator

Re: Eclipse Plugin and URLClassLoader [message #491117 is a reply to message #491112] Tue, 13 October 2009 11:33 Go to previous message
StefanK  is currently offline StefanK Friend
Messages: 25
Registered: July 2009
Junior Member

we created a new 4GL for our project, this 4GL is parsed to java code via generator. The created "test".java and "test".class can be loaded by the code posted above without any problems. But if I try to load the .class files that are created by eclipse, the problem descibed above occures.

Now I´m much more clueless than before Confused

Best Regards
Previous Topic:Disable Context Menu in the TextCellEditor
Next Topic:blockOnOpen = false for Wizards
Goto Forum:

Current Time: Sat May 26 13:59:06 GMT 2018

Powered by FUDForum. Page generated in 0.01577 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top