From owner-freebsd-hackers Mon Oct 21 11:27:28 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id LAA02288 for hackers-outgoing; Mon, 21 Oct 1996 11:27:28 -0700 (PDT) Received: (from hsu@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id LAA02282; Mon, 21 Oct 1996 11:27:26 -0700 (PDT) Date: Mon, 21 Oct 1996 11:27:26 -0700 (PDT) From: Jeffrey Hsu Message-Id: <199610211827.LAA02282@freefall.freebsd.org> To: hackers, questions, root@swd.928.com.tw Subject: Java CLASSPATH Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk 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.