J2EEOnline J2EEOnline


Java Basics  «Prev 

Defining and importing Packages

Package Organization

Classes and packages are organized into a hierarchy of directories.
For example, if you have a package called MyPackage and a class called Alpha , you can compile your source code like this:

javac -d . Alpha.java

The current directory is indicated by "." and is where the source code resides. The compiler will place Alpha.class in the directory MyPackage , below the current directory. For another example, say you compile a file with the following command:

javac -d /User_Programs/Java/classes

and the file's package statement says:
package MyPackage.MyClass

You will find the compiled class in the directory:
/User_Programs/Java/classes/MyPackage/MyClass