I don't think the tutorial is available on dic or pdf format. You get a selection of download-able versions here, but they appear all to be in html. There may be some parts of the tutorial which are only available in the on-line version.
If you have a large application, then you put files which are related into packages by writing as the very first statement of your file, before the import statements. You usually keep package names short, and use lower case only.
You can have packages inside packages: the Math class starts with
If you are planning to let your application out into the big wide world, it is usual to start your package name with your website URL, without the www, written backwards. That is how you get pacakge names starting in com.sun.
As I said, the use of a package declaration means you can keep classes which are related to one another together. You can have classes with the same name in different packages. You can use classes from your other packages by using an import statement in the usual fashion. You can compile every class in a package and zip the whole lot up as a .jar and import the jar into a build path for a different project.
Beware: If you are using packages and compiling from command prompt you have to use a certain sequence of instructions:-
Don't put any of the .java files into a particular folder; keep them all in the same folder regardless.
Compile the files in the deepest packages first. That means the files "farthest" from the main method.
Use the following sort of instruction to compile: C:\MyJavaProgramsFolder> javac -d . MyClass.java
-d means to put the .class files into a directory, and the . means to start with the "." directory, ie the current directory you happen to be in.
If you get any compiler errors like "Cannot find symbol: class Foo," compile Foo on its own with -d . included
Compile the class with the main method last. Use the same sort of instruction as above with "-d ."
If your main method is in package bar in class FooTest, start the app off with the instruction java bar.FooTest
Joined: Oct 13, 2005
Further to my previous posting.
If you start off with all your .java files in one folder, you will find the Java compiler creates directories corresponding in name to the packages and subpackages. If you use IDEs, they all have different approaches to where they put the .java and .class files.
And if you have two questions, you would have done better to start two threads. Poeple reading the title of this thread will think it is only about how to get the tutorial.