Programming in Java I

Syllabus -- CS 211

Week 1

Review of Resources:

The CD-ROM that accompanies "Java Software Solutions" contains:

- Java(TM) 2 SDK, Standard Edition (for Microsoft Windows)

- Forte for Java Community Edition (for Microsoft Windows)

- Slides in PowerPoint 97 format

- Keyboard materials

- Example programs

The author's web site (http://ss.villanova.edu) contains additional

resources and updated information.

Sample Java Program

//------

//********************************************************************

// Lincoln.java Author: Lewis and Loftus

//

// Demonstrates the basic structure of a Java application.

//********************************************************************

public class Lincoln

{

//------

// Prints a presidential quote.

//------

public static void main (String[] args)

{

System.out.println ("A quote by Abraham Lincoln:");

System.out.println ("Whatever you are, be a good one.");

}

}

//------

Style and Documentation Guidelines

Appendix G

Be sure to put the following comments at the top of each of your programs with the appropriate information included.

// File name: (your file name here)
// Author(s): (your name(s))
// Email Address: (your e-mail address)
// Programming Project # (put in the appropriate number for the project)
// Description: (briefly describe what the program does)

Sequence of creating and running a Java program;

Create a program with a text editor.

Compile the program into Java Bytecode

Use a Java interpreter to “run” the program

Java Compiler

Translates java instructions from source code to Java bytecode.

Interpreter

Translates a bytecode instruction to machine code and then carries out the instruction.

A compiler and interpreter are in the Java 2 SDK (Software Development Kit )

Install Java 2 SDK on your machine

Installing JDK 1.3

·  For windows, simply run the executable j2sdk1_3 file on the CD from the Lewis and Loftus textbook. Follow the directions for installation.

·  Additional directions are available in README.html, also in the Java SDK folder.

To download Java 2 SDK for platforms other than Microsoft Windows or to get a more recent version, obtain the SDK directly from Sun, at www.java.sun.com/j2se/1.3/download-windows.html.

o  On this page you can also browse or download documentation for jdk1.3. (20 Meg of disk space). Or browse the documentation online without downloading it.

Development Environment

The software tools used to create, test, and execute programs.

Some different development environments available at DePaul for Java programs

.

Command Line Interface

1)  DOS – basic with SDK 2. (javac, java) Command line interface

2) TextPad – Text Editor integrated with java compilation and execution

3) Bluej –lightweight integrated development environment (IDE)

  1. Download bluej-114.jar, installation instructions and BlueJ Tutorial from www.bluej.org
  2. Install the software
  3. Run the software by either going into DOS and executing bluej.bat or set up an icon short cut per instructions from the bluej site.

4)  Forte -- heavyweight IDE

  1. Use the Lewis and Loftus CD from the textbook. Double click on the executable file forte_ce_2.exe. Follow the directions for installation.
  2. Additional directions are available in forte_ce_install
  3. Run the software by clicking on the icon.

3