Dynamic class loading
Per Bothner
per@bothner.com
Sat Apr 1 00:00:00 GMT 2000
Bryce McKinlay <bryce@albatross.co.nz> writes:
> And, of course, it searches for these .so files on LD_LIBRARY_PATH,
> not CLASSPATH. Personally I'm not sure that confusing the two is
> really a good idea. CLASSPATH is for class files, not
> system-dependent native code. And if we start putting .so's on
> there, it could potentially cause problems with existing java
> applications.
Possibly, but I'd like a specific scenario likely to cause trouble.
I don't see why CLASSPATH can't contain system-dependent native code.
CLASSPATH specifies a search path of "logical directories", i.e.
places to look for Java classes. If you have a bunch of Java classes,
you can "install" them on your system in three ways: as a directory
containing .class files; as a .zip or .jar archive; as a .so archive.
I think logically, you should use CLASSPATH for all of them.
Notice that System.loadLibrary is a separate issue. LD_LIBRARY_PATH
is used for searching for .so files; CLASSPATH is used for searching
for Java classes. Native JNI methods are found using LD_LIBRARY_PATH,
unless they have been statically linked somehow. Native CNI methods
can be found using either LD_LIBRARY_PATH, or they can be linked into
the same .so files that contains the Java Class objects, in which
case they are found using CLASSPATH.
--
--Per Bothner
per@bothner.com http://www.bothner.com/~per/
More information about the Java
mailing list