[3415] in java-interest

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

Re: organization of class path

daemon@ATHENA.MIT.EDU (Thomas Ball)
Fri Nov 10 18:51:06 1995

Date: Fri, 10 Nov 1995 11:40:00 -0800
From: Thomas.Ball@Eng.Sun.COM (Thomas Ball)
To: garya@village.org
Cc: java-interest@java.Eng.Sun.COM

You *can* build a package without changing your classpath.  Package
names map to subdirectories, so package source files should normally be
in a subdirectory from where you build.  Instead of:

	cd MyPkg
	javac MyClass.java
	cd ..
	java MyPkg.MyClass

try staying in the top directory:

	javac MyPkg/MyClass.java
	java MyPkg.MyClass

This also eases development of component packages, where your main()
might be in top-level client code, and references package classes.
Staying at the root of your development tree helps keep that global
view of a project you need as it's designed.

Tom Ball
Java Products Group

>  It seems that one should be able to build a package in a single directory
>  without applying a special CLASSPATH to get it to compile.  However, this
>  doesn't seem to be the case.
>  
>  Consider a directory MyPkg which contains .java files for the classes
>  in MyPkg.  Seems like one should be able to:
>  
>  	cd MyPkg
>  	javac MyClass.java
>  
>  and have it work, for all files *.java which look like:
>  
>  Package MyPkg
>  
>  class MyClass {
>  }
>  
>  All classes in MkPkg are automatically supposed to be imported.  
>  However, CLASSPATH must include ".." for this to work.
>  I was going to suggest that ".." be included in the default CLASSPATH,
>  but unfortunately this also gets you any other packages which happen to
>  be in "..", which is not particularly desireable.  Is there a way out
>  of this delimma?
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

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