PreviousNextTracker indexSee it online !

(64/231) 2423910 - JARClassLoader's URLs are not understood by Ant's Locator

JARClassLoader's URLs are not understood by Ant's Locator.

This causes the javah ant task to fail if the ant target is invoked from
AntFarm using jEdit's JVM.

The problem arises as the javah task first obtains a class object with a call to Class.forName("") and then asks Ant's Locator to find the path to this class' containing jar file (which the javah task uses as a means to locate tools.jar).


This becomes a problem when Ant is run from AntFarm in jEdits JVM as the class is loaded using the JARClassLoader. Ant's Locator then calls the JARClassLoader's getResource(String name) and tries to determine the path to the jar file from the returned URL.

However JARClassLoader returns a URL like this

But Locator does not understand the jeditresource: protocol (and even if it did the URL lacks the full path information to tools.jar anyway).

Subsequently the javah task then invokes java without tools.jar in the classpath resulting in
java.lang.NoClassDefFoundError: com/sun/tools/javah/oldjavah/Main

For a quick fix I tweaked my build of jEdit so that JARClassLoader
returns URLs in the form
These URLs are then understood by Locator and thus this fixes the javah task. I don't know if this is the best way to fix this, or what other problems this may introduce.

Submitted nigelt - 2008-12-13 - 13:36:38z Assigned nobody
Priority 5 Category editor core
Status Open Group None
Resolution None Visibility No