Welcome To Java !

Java SETUP JRE , Packages , Library

Simple Application , Style , Errors

JavaDoc and Jar Overview

IDE Setup and First Intro to Java

  

ITS training programs up to-date
I have elected one
My valued time I dedicate
To Java from the Sun...

- Emily Dickinson :-) on the Internet Technology School (ITS)

Your instructor is Jeff Zhuk. Welcome!


What is

1. . . . . .
2. . . . .
3. . . .
? . . .

·        Java (JDK) SETUP for UNIX and Windows XP/Vista/Windows7

Download from Oracle and install JavaSE 1.7 JDK; Place it in the C:\JDK – directory

Create Environment Variables: Control Panel – System – Advanced – Environment Variables – NEW:

JAVA_HOME=C:\JDK

JDK_HOME=C:\JDK

Java looks up its system classes in a default location. If the classes are not in the default location, Java will look them up relative to the directories specified by the Classpath. It looks up user-defined classes in areas relative to the CLASSPATH environment variable. Java looks up the classes in the order specified by the Classpath.

In the case you prefer manual setup instead of using a wizard-installer:

Setup for UNIX

Lines in the setup file: $HOME/.profile

PATH=.:$PATH:/jdk/bin
export PATH
CLASSPATH=.:/jdk/jre/lib:$CLASSPATH
export CLASSPATH

Setup for Windows XP/Vista/Windows7

Lines in the setup file: c:\autoexec.bat

PATH=%PATH%;c:\jdk\bin
set CLASSPATH=.;c:\jdk\jre\lib;%CLASSPATH%

 In the JDK, there are three search paths that are used to find classes: The first place where java looks for classes is the bootstrap classpath. The value of this path can be examined by calling System.getProperty("sun.boot.class.path"). Note that the prefix "sun." shows that, at least for now, this property is specific to Sun's implementation.

The second place where java looks for classes is the extension directories. The list of directories can be examined by calling System.getProperty("java.ext.dirs").

The third and last place where java looks for classes is the application classpath. The value of this path can be examined by calling System.getProperty("java.class.path").

 

2. Download and Install Eclipse JEE: http://Eclipse.org – Eclipse Indigo JEE – Unzip it directly to C:\


Main Packages

A Java package is a collection of related classes. When you are creating a Java applet or application, it is a good practice to put it into its own package. If the application is large, the package can be broken down to several smaller packages.

The example below displays an itschool package that has several smaller, more manageable packages. Using classes from these packages is simple.

Packages in a package: examples and explanations

itschool.gui

itschool.graph

itschool.data

itschool.misc

Using packages

You can tell the compiler to import a whole package or just one class from the package. 
If you only need one or two classes from a package, importing only the specific class is more efficient. 
If you are using several classes from a package, importing the whole package is easier. 
Which ever way you choose will only impact compile time and not run time efficiency.

The first example below tells the compiler that all of the classes in the itschool.gui package are candidates for use.

The second statement says only to look at the UtDate.class in the itschool.misc package.

Examples of Using packages

import itschool.gui.*;

import itschool.misc.UtDate;

Creating a package

Creating a package is simple. Create a directory with the same name and path as your package name. Each dot separating a word in the package name is a directory in the path. The first executable line of code in the class needs to start with the keyword package and then the package name.

Package statement

package itschool.gui;


Jeff.Zhuk@JavaSchool.com