[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] Re: Recipe to get extension bundle classes on the class path

>> As I've been trying to move toward using the Equinox launcher to start
>> up the framework, with the launcher JAR or the native "eclipse.exe"
>> executable being the user's means of starting the program, I'm not sure
>> how to put any of my classes on the class path as seen by
>> SystemClassLoader.
> That's actually quite interesting. After a cursory look at the code it
> looks very tough indeed to make resources available via the System class
> loader when using eclipse.exe as the launcher takes over
> java.lang.classpath. I'll verify and perhaps open an enhancement request.
>> [...]

As any change to the value of java.lang.classpath is not picked up after
the java runtime is initialized, the option exists to specify an
additional URL to be used by the system classloader.  Adding another URL
classloader may be done using reflection, something like this:


File fileToAdd = new File("HelloWorld.class") ;
URL u = fileToAdd.toURL() ;

URLClassLoader sysLoader =
Class sysLoaderClass = URLClassLoader.class;

 //use reflection to invoke the private addURL method
Method method = sysLoaderClass.getDeclaredMethod("addURL", new Class[]
method.invoke(sysLoader, new Object[] {u});