This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Dynamic class loading


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/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]