Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Oct 1996 11:27:26 -0700 (PDT)
From:      Jeffrey Hsu <hsu>
To:        hackers, questions, root@swd.928.com.tw
Subject:   Java CLASSPATH
Message-ID:  <199610211827.LAA02282@freefall.freebsd.org>

Next in thread | Raw E-Mail | Index | Archive | Help
The Java interpreter looks for a class using the following algorithm.

  1. Take the class name and append '.class' to it to form a filename.

	Object -> Object.class

  2. Take the package of the class, replace the dots with slashes,
     and prepends that directory to the filename in step 1.

	Object is in the java.lang package so the class java.lang.Object,
	 gets transformed into the path java/lang/Object.class.
	If the class doesn't have a package, then it uses the current
	  directory, '.'.

  3.  For every element in your CLASSPATH, look for the path formed in step 2.

	% setenv CLASSPATH .:/usr/local/java/classes.zip:/usr/lib/classes

	This CLASSPATH has 3 elements: 2 directories, . and /usr/lib/classes,
	and one zip file /usr/local/java/classes.zip.  Zip files are
	collections of files with the full pathname of the files preserved.

	Given this CLASSPATH, first the Java interpreter looks in
	. for java/lang/Object.class, then it looks in the zipfile
	/usr/local/java/classes.zip for java/lang/Object.class,
	and finally, it looks in /usr/lib/classes for java/lang/Object.class.



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?199610211827.LAA02282>