[495] in java-interest

home help back first fref pref prev next nref lref last post

Re: Still confused on classpath

daemon@ATHENA.MIT.EDU (Jonathan Payne)
Sun Jun 25 21:53:45 1995

Date: Sun, 25 Jun 1995 18:32:54 -0700
From: jpayne@starwave.com (Jonathan Payne)
To: perry@OpenMarket.com
Cc: java-interest-digest@java.sun.com, perry@OpenMarket.com
In-Reply-To: <199506252243.SAA23107@networkxxiii.openmarket.com> (message from Jeffrey Perry on Sun, 25 Jun 1995 18:43:56 -0400)

> X-Mailer: exmh version 1.6 4/21/95
> Cc: perry@OpenMarket.com
> Mime-Version: 1.0
> Date: Sun, 25 Jun 1995 18:43:56 -0400
> From: Jeffrey Perry <perry@OpenMarket.com>
> Sender: owner-java-interest@java.sun.com
> Precedence: bulk
> X-Info: To unsubscribe, send 'unsubscribe' to java-interest-request@java.sun.com
> Content-Type: text/plain; charset=us-ascii
> Content-Length: 1451
> 
> I am still trying to figure out the CLASSPATH enviroment variable and how
> it is used in compiles and also by HotJava. Perhaps someone could clarify this
> for me.
> 
> 1) Does HotJava itself use this environment variable?
>    I believe it does because jpayne from starwave has a warning in his
>    embedded component docs saying that new classes such as his need to be
>    in CLASSPATH when compiling but should not be when running HotJava or
>    you will not be able to run applets using the classes but located somewhere
>    else.

To clarify, HotJava is a java application.  Java uses CLASSPATH to
figure out where to find classes that are loaded as they are needed by
the interpreter.

And it just so happens that the compiler uses that same CLASSPATH
variable to find classes that (1) you are compiling against, e.g., all
the system classes, and (2) the classes you are compiling and their
dependencies.  Oops, I think that was redundant.

> 2) Do I need a final slash on directory names in the CLASSPATH environment
>    variable?

No.

> 3) If the class is in directory /hotjava/mydev/classes should i put
>    /hotjava/mydev/classes in the path or just /hotjava/mydev ?
>    I may be getting confused with the SRC part of the apptag.

Java just prepends the elements of your CLASSPATH to the name of the
class you are looking for.  So if you're looking for
app.text.TextView, then it looks in

	/hotjava/mydev/classes/app/text/TextView.class

BUT, HotJava, when it loads classes over the network, looks in the
same directory as the .html file your app is in FOR A SUBDIRECTORY
called classes, and then appends the class name to that.  E.g., you
have <app class="mypackage.myclass"> in

	http://mymachine/~mylogin/myfile.html

and HotJava looks for mypackage.myclass in

	http://mymachine/~mylogin/classes/mypackage/myclass.class

> 4) Is there any way to tell the AppletViewer applet to use CLASSPATH rather
>    than having to manually tell it where to look?

I don't know.  I don't like the AppletViewer because there's currently
no option for reloading the applet.  When running with HotJava, you
can reload your applet as many times as you like.  Unfortunately, as
the new classes are all loaded, the old ones are not thrown away, so
keep that in mind.  But at least you don't have to start up HotJava
each time.  BUT, if your classes for your applet are in your
classpath, then they will be loaded from the file system, AND, classes
that are loaded from the file system are never EVER reloaded from the
file system.  That's just a characteristic of classes loaded over the
network.

> 5) How do directories under a class directory in the CLASSPATH handled?
>    Are they searched automatically? If the user specifies explicitly the 
>    package name in the html source? ex: app.TestPanel3

I think the answer to your question is Yes.  My above examples should
explain this.  A class' name is always the fully qualified class name
including the packages and the class name.  E.g., app.TestPanel3 is
THE one and only name for that class.  In Java, when you say

	import app.TestPanel3;

then, and only then, you are allowed to refer to that class without
all the package information.  But in the network context, where there
is no compiler around, you must fully qualify the class name.  Each
each level in the package hierarchy corresponds to a level in the
directory structure.

If you are still having trouble, give me a call (206) 957-3090 and I
will walk you through some of this.  I know you have been trying to
get something started for a while now.

JP
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post