CIS 103 * Programmin Logic and Design

Download Report

Transcript CIS 103 * Programmin Logic and Design

Java PAL

Contains the development kit and the runtime
environment ( aka the Java Virtual Machine )

Download Link:
http://java.sun.com/javase/downloads/index.jsp

Installation
◦ Detailed instructions in the “Read This Before You Begin” section.
◦ Environment Variables
 Path
 Classpath

Originally was to be called “Oak”

Open Source Software ( free!! )

Mainframes, minicomputers, servers, desktops,
notebooks, mobile devices, intelligent consumer
devices

Windows, Linux, Unix, Macintosh, etc.


Application Programming Interface
Class Library

Packages
◦ Classes
 Methods
 Statements

http://java.sun.com/javase/6/docs/api/

Application
◦ A stand-alone program that runs on a computer.

Applet
◦ An applet is a Java program that is executed and viewed in a
browser ( IE, Firefox, Navigator, etc. )

Servlet
◦ A servlet is a Java program that runs on a Web server or
application server and provides server-side processing such as
accessing a database and e-commerce transactions.
◦
An object represents something in the real world, such
as a car, an employee, or an item in an inventory.
◦
Objects encapsulate attributes and behavior
 An attribute is a piece of information
 A behavior is an operation that may be used to manipulate the
value of an attribute

Reusable software components that model real-world items

Look all around you
 People, animals, plants, cars, etc.

Attributes
 Size, shape, color, weight, etc.

Behaviors
 Babies cry, crawl, sleep, etc.

Even though Java is an object-oriented programming language, we will be
doing procedural programming using the language. In the CIS 182/282
courses you will explore object-oriented programming in Java.

Java programs go through five phases:
◦ Edit
 Programmer writes program using an editor; stores program on disk with the
.java file name extension
◦ Compile
 Use javac (the Java compiler) to create bytecodes from source code program;
bytecodes stored in .class files
◦ Load
 Class loader reads bytecodes from .class files into memory
◦ Verify
 Bytecode verifier examines bytecodes to ensure that they are valid and do not
violate security restrictions
◦ Execute
 Java Virtual Machine (JVM) uses a combination of interpretation and just-in-time
compilation to translate bytecodes into machine language

Classes are the fundamental unit of programming in
Java.

Classes may be composed of:
◦ variables
◦ methods
corresponds to attributes
corresponds to behaviours
public class HelloWorld
{
public static void main(String args[])
{
System.out.println(“Hello World!”);
}
}



class is:
method is:
header:
HelloWorld
main
public static void main(String args[])

A translator translates a program (class) in one
language into another (often a machine language).

A translator may be a:
◦ compiler
◦ interpreter

translate only
translate and execute
Java uses both a compiler and an interpreter ( as do
applications in the Visual Studio environment )

If you successfully compile a Java class, you produce a
class file.
This is a file with the same name as the program but
with a .class extension

A Class file contains an intermediate language or
virtual machine language.
In Java this intermediate language is called bytecode.