Software Engineering
Java Platform and Basics

Course Map

Agenda

Java Platform

The Java platform is not a specific hardware or operating system, but rather an execution environment called a JRE (Java Runtime Environment) implementing JVM (Java Virtual Machine) , and a set of standard libraries (APIs) which provide common functionality.
The platform was called the Java 2 Platform although the "2" has been dropped, and includes both a Standard Edition or Java SE, an Enterprise Edition Java EE), and a Micro Edition or Java ME. The current version of the Java SE platform is alternatively specified as version 1.5 or version 5 (both refer to the same version). A good overview of the myriad of technologies that makes up the Java 2 Platform SE 5 (Java SE 5) can be found on the JDK Documentation Page.

J2SE 6.0 will become Java SE 6 (code name Mustang), and J2SE 7.0 will become Java SE 7 (code name Dolphin).

"Hello, World" in Java

"Hello, World" in Java

"Hello, World" in Java

Using the SDK


Executable JAR File

Putting your program in a JAR allows it to be distributed as a single executable file, saving space and simplifying the download process.

Here is the general procedure for creating an executable JAR:

  1. Compile your java code, generating all of the program's class files.
  2. Create a manifest file containing the following 2 lines:
    Manifest-Version: 1.0
    Main-Class: name of class containing main

    The name of the file should end with the .mf suffix. It is important that the file ends with a blank line.

  3. To create the JAR, type the following command:
    jar cmf manifest-file jar-file input-files

    The input-files must include any class files, images, sounds, etc. that your program uses. Optionally, you can include the program's .java files in the JAR. See below for adding directories ot the JAR.

  4. To view the contents of the JAR, type:
    jar tf jar-file
  5. Execute the application from the command line by typing:
    java -jar jar-file

Executing GreeterTester.jar File

Let's say we wanted to distribute the simple program GreeterTester.java as a JAR. First, we create a text file named GreeterTester.mf which contains:

Manifest-Version: 1.0
Main-Class: GreeterTester

Then, we create the archive by typing:

jar cmf GreeterTester.mf GreeterTester.jar Greeter.class GreeterTester.class

and run it by typing:

java -jar GreeterTester.jar
The file GreeterTester.jar can now be downloaded and executed.

Using BlueJ

Using BlueJ


Documentation Comments

Documentation Comments - Summary


Documentation Comments - Detail


Documentation Comments

Documentation Comments - API Docs


Primitive Types

Control Flow

Object References

The null Reference

The this Reference

Parameter Passing

No Reference Parameters

Packages

Packages

Importing Packages

Importing Packages

Packages and Directories

Exception Handling

Checked and Unchecked Exceptions

Declaring Checked Exceptions

Catching Exceptions

The finally Clause

Strings

Strings

String concatenation

Converting Strings to Numbers

Reading Input

The ArrayList<E> class

The ArrayList<E> class

An array list is a collection of objects that supports efficient access to all storage locations.

The ArrayList<E> class

Linked Lists

List Iterators

List Iterators

Arrays

Arrays

Arrays

Command-Line Arguments

Static (Class) Fields

Static (Class) Methods

Programming Style: Case Convention

Programming Style: Property Access

Programming Style: Braces

Programming Style: Fields

Programming Style: Miscellaneous