100% found this document useful (1 vote)
389 views12 pages

Java Programming Basics and IDEs

The document introduces key concepts in Java programming including: - The chapter objectives are to understand computer basics, programs, operating systems, Java, the Java language specification, API, JDK, IDEs, and how to write, compile, and run simple Java programs. - It discusses Java editions like J2SE for developing standalone apps/applets, J2EE for server-side apps, and J2ME for mobile apps. This book uses J2SE. - Popular Java IDEs like NetBeans and Eclipse are presented for developing Java programs. The document provides examples of creating a simple Java program in Notepad and compiling/running it from the command line.

Uploaded by

Maha Al ahmari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
389 views12 pages

Java Programming Basics and IDEs

The document introduces key concepts in Java programming including: - The chapter objectives are to understand computer basics, programs, operating systems, Java, the Java language specification, API, JDK, IDEs, and how to write, compile, and run simple Java programs. - It discusses Java editions like J2SE for developing standalone apps/applets, J2EE for server-side apps, and J2ME for mobile apps. This book uses J2SE. - Popular Java IDEs like NetBeans and Eclipse are presented for developing Java programs. The document provides examples of creating a simple Java program in Notepad and compiling/running it from the command line.

Uploaded by

Maha Al ahmari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

8/22/18

Objectives
Chapter 1: Introduction to ✦ To understand computer basics, programs, and operating systems (§§1.2–1.4).

Computers, Programs, and Java ✦ To describe the relationship between Java and the World Wide Web (§1.5).

✦ To understand the meaning of Java language specification, API, JDK, and IDE
(§1.6).
✦ To write a simple Java program (§1.7).
CS1: Java Programming ✦ To display output on the console (§1.7).

Colorado State University ✦ To explain the basic syntax of a Java program (§1.7).
✦ To create, compile, and run Java programs (§1.8).
✦ To use sound Java programming style and document programs properly (§1.9).

Original slides by Daniel Liang ✦ To explain the differences between syntax errors, runtime errors, and logic
errors (§1.10).
Modified slides by Chris Wilcox ✦ To develop Java programs using NetBeans (§1.11).

✦ To develop Java programs using Eclipse (§1.12).

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
1 2
rights reserved. rights reserved.

JDK Editions Popular Java IDEs


✦ Java Standard Edition (J2SE)
✦ NetBeans
– J2SE can be used to develop client-side standalone
applications or applets. ✦ Eclipse
✦ Java Enterprise Edition (J2EE)
– J2EE can be used to develop server-side applications
such as Java servlets, Java ServerPages, and Java
ServerFaces.
✦ Java Micro Edition (J2ME).
– J2ME can be used to develop applications for mobile
devices such as cell phones.
This book uses J2SE to introduce Java
programming.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
3 Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
4
rights reserved. rights reserved.

A Simple Java Program Creating and Editing Using NotePad


Listing 1.1 To use NotePad, type
// This program prints Welcome to Java! notepad Welcome.java
public class Welcome { from the DOS prompt.
public static void main(String[] args) {
System.out.println("Welcome to Java!");
}
}

Note: Clicking the green button displays the source code


with interactive animation. You can also run the code in
Welcome
a browser. Internet connection is needed for this button.
Run Note: Clicking the blue button runs the code from
Windows. If you cannot run the buttons, see
www.cs.armstrong.edu/liang/javaslidenote.doc.

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
5 6
rights reserved. rights reserved.

1
8/22/18

Creating, Compiling, and


Running Programs Compiling Java Source Code
You can port a source program to any machine with appropriate
compilers. The source program must be recompiled, however, because
the object program can only run on a specific machine. Nowadays
computers are networked to work together. Java was designed to run
object programs on any platform. With Java, you write the program
once, and compile the source program into a special type of object
code, known as bytecode. The bytecode can then run on any computer
with a Java Virtual Machine, as shown below. Java Virtual Machine is
a software that interprets Java bytecode.

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
7 8
rights reserved. rights reserved.

animation animation

Trace a Program Execution Trace a Program Execution


Enter main method Execute statement

// This program prints Welcome to Java! // This program prints Welcome to Java!
public class Welcome { public class Welcome {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("Welcome to Java!"); System.out.println("Welcome to Java!");
} }
} }

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
9 10
rights reserved. rights reserved.

animation

Trace a Program Execution Two More Simple Examples

// This program prints Welcome to Java!


public class Welcome {
public static void main(String[] args) {
System.out.println("Welcome to Java!");
} WelcomeWithThreeMessages Run
}
ComputeExpression Run

print a message to the


console

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
11 12
rights reserved. rights reserved.

2
8/22/18

Anatomy of a Java Program Class Name


✦ Class name Every Java program must have at least one class.
Each class has a name. By convention, class names
✦ Main method
start with an uppercase letter. In this example, the
✦ Statements class name is Welcome.
✦ Statement terminator
// This program prints Welcome to Java!
✦ Reserved words public class Welcome {
✦ Comments public static void main(String[] args) {
System.out.println("Welcome to Java!");
✦ Blocks }
}

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
13 14
rights reserved. rights reserved.

Main Method Statement


A statement represents an action or a sequence of actions.
Line 2 defines the main method. In order to run a
The statement System.out.println("Welcome to Java!") in
class, the class must contain a method named main. the program in Listing 1.1 is a statement to display the
The program is executed from the main method. greeting "Welcome to Java!“.

// This program prints Welcome to Java! // This program prints Welcome to Java!
public class Welcome { public class Welcome {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("Welcome to Java!"); System.out.println("Welcome to Java!");
} }
} }

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
15 16
rights reserved. rights reserved.

Statement Terminator Reserved words


Reserved words or keywords are words that have a
Every statement in Java ends with a semicolon (;). specific meaning to the compiler and cannot be used for
other purposes in the program. For example, when the
compiler sees the word class, it understands that the word
after class is the name for the class.

// This program prints Welcome to Java! // This program prints Welcome to Java!
public class Welcome { public class Welcome {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("Welcome to Java!"); System.out.println("Welcome to Java!");
} }
} }

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
17 18
rights reserved. rights reserved.

3
8/22/18

Blocks Special Symbols


A pair of braces in a program forms a block that groups
components of a program. Character Name Description

{} Opening and closing Denotes a block to enclose statements.


braces
() Opening and closing Used with methods.
parentheses
[] Opening and closing Denotes an array.
brackets
public class Test { // Double slashes Precedes a comment line.
Class block
public static void main(String[] args) {
System.out.println("Welcome to Java!"); Method block " " Opening and closing Enclosing a string (i.e., sequence of characters).
} quotation marks
} ; Semicolon Marks the end of a statement.

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
19 20
rights reserved. rights reserved.

{ …} ( … )

// This program prints Welcome to Java! // This program prints Welcome to Java!
public class Welcome { public class Welcome {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("Welcome to Java!"); System.out.println("Welcome to Java!");
} }
} }
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
21 22
rights reserved. rights reserved.

; // …

// This program prints Welcome to Java! // This program prints Welcome to Java!
public class Welcome { public class Welcome {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("Welcome to Java!"); System.out.println("Welcome to Java!");
} }
} }
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
23 24
rights reserved. rights reserved.

4
8/22/18

Programming Style and


"…" Documentation
✦ Appropriate Comments
✦ Naming Conventions
✦ Proper Indentation and Spacing Lines

// This program prints Welcome to Java! ✦ Block Styles


public class Welcome {
public static void main(String[] args) {
System.out.println("Welcome to Java!");
}
}
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
25 26
rights reserved. rights reserved.

Appropriate Comments Naming Conventions


✦ Choose meaningful and descriptive names.
Include a summary at the beginning of the
program to explain what the program does, its key ✦ Class names:
features, its supporting data structures, and any – Capitalize the first letter of each word in the
unique techniques it uses. name. For example, the class name
ComputeExpression.
Include your name, class section, instructor, date,
and a brief description at the beginning of the
program.

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
27 28
rights reserved. rights reserved.

Proper Indentation and Spacing Block Styles


✦ Indentation Use end-of-line style for braces.
– Indent two spaces.
Next-line public class Test
style {

✦ Spacing
public static void main(String[] args)
{
System.out.println("Block Styles");
– Use blank line to separate segments of the code. }
}

End-of-line
style
public class Test {
public static void main(String[] args) {
System.out.println("Block Styles");
}
}

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
29 30
rights reserved. rights reserved.

5
8/22/18

Programming Errors Syntax Errors


public class ShowSyntaxErrors {
✦ Syntax Errors public static main(String[] args) {
System.out.println("Welcome to Java);
– Detected by the compiler }
✦ Runtime Errors }
– Causes the program to abort
✦ Logic Errors
– Produces incorrect result

ShowSyntaxErrors Run

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
31 32
rights reserved. rights reserved.

Runtime Errors Logic Errors


public class ShowRuntimeErrors { public class ShowLogicErrors {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(1 / 0); System.out.print("Celsius 35 is ");
} System.out.print("Fahrenheit ");
System.out.println((9 / 5) * 35 + 32);
}
}
}

ShowRuntimeErrors Run ShowLogicErrors Run

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
33 34
rights reserved. rights reserved.

Companion
Website Compiling and Running Java Displaying Text in a Message
from Eclipse Dialog Box
✦ See Supplement II.D on the Website for details you can use the showMessageDialog method in the
JOptionPane class. JOptionPane is one of the many
predefined classes in the Java system, which can be
reused rather than “reinventing the wheel.”

WelcomeInMessageDialogBox Run

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
35 36
rights reserved. rights reserved.

6
8/22/18

The showMessageDialog Method Two Ways to Invoke the Method


There are several ways to use the showMessageDialog
JOptionPane.showMessageDialog(null,
method. For the time being, all you need to know are
"Welcome to Java!", two ways to invoke it.
"Display Message",
One is to use a statement as shown in the example:
JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, x,
y, JOptionPane.INFORMATION_MESSAGE);
where x is a string for the text to be displayed, and y is
a string for the title of the message dialog box.
The other is to use a statement like this:
JOptionPane.showMessageDialog(null, x);

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
37
where x is a string for the text to be displayed.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
38
rights reserved. rights reserved.

Implicit Import and Explicit Import What is a Computer?


java.util.* ; // Implicit import A computer consists of a CPU, memory, hard disk, floppy disk,
monitor, printer, and communication devices.

java.util.JOptionPane; // Explicit Import

Bus

No performance difference Storage


Memory CPU
Communication
Devices
Input
Devices
Output
Devices
Devices
e.g., Disk, CD, e.g., Modem, e.g., Keyboard, e.g., Monitor,
and Tape and NIC Mouse Printer

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
39 40
rights reserved. rights reserved.

CPU Memory
The central processing unit (CPU) is the brain of a computer. It Memory is to store data and program instructions for CPU to
retrieves instructions from memory and executes them. The CPU execute. A memory unit is an ordered sequence of bytes, each holds
speed is measured in gigahertz (GHz), with 1 gigahertz equaling 1 eight bits. A program and its data must be placed in memory before
billion cycles per second. The speed of the CPU has been improved they can be executed. A memory byte is never empty, but it can be
continuously. If you buy a PC now, you might get an Intel Core i7 uninitialized. The current content of a memory byte is overwritten
running at 2.8 to 4.0 gigahertz. whenever new information is placed in it. If you buy a PC today, it
might have 8 gigabytes (Gb) of memory.
Bus Bus

Storage Communication Input Output Storage Communication Input Output


Memory CPU Devices Devices Devices Memory CPU Devices Devices Devices
Devices Devices

e.g., Disk, CD, e.g., Modem, e.g., Keyboard, e.g., Monitor, e.g., Disk, CD, e.g., Modem, e.g., Keyboard, e.g., Monitor,
and Tape and NIC Mouse Printer and Tape and NIC Mouse Printer

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
41 42
rights reserved. rights reserved.

7
8/22/18

How Data is Stored? Storage Devices


Data of various kinds, such as numbers,
characters, and strings, are encoded as a
Memory is volatile, because information is lost when the power is
series of bits (zeros and ones). Computers off. Programs and data are permanently stored on storage devices
use zeros and ones because digital devices Memory address Memory content
and are moved to memory when the computer actually uses them.
have two stable states, which are referred to
as zero and one by convention. The . . There are three main types of storage devices: disk drives (hard
programmers need not to be concerned about . . disks and floppy disks), optical drives (CD, DVD), and tape drives.
. .
the encoding and decoding of data, which is 2000 01001010 Encoding for character ‘J’
If you buy a PC today, it might have a 500 gigabyte (Gb) or 1
performed automatically by the system based
on the encoding scheme. The encoding
2001
2002
01100001
01110110
Encoding for character ‘a’ terabyte (Tb) hard drive, or solid state storage.
Encoding for character ‘v’ Bus
scheme varies. For example, character ‘J’ is 2003 01100001 Encoding for character ‘a’
represented by 01001010 in one byte. A 2004 00000011 Encoding for number 3
small number such as three can be stored in a
Storage Communication Input Output
single byte. If computer needs to store a Devices
Memory CPU Devices Devices Devices
large number that cannot fit into a single
e.g., Disk, CD, e.g., Modem, e.g., Keyboard, e.g., Monitor,
byte, it uses a number of adjacent bytes. No Printer
and Tape and NIC Mouse
two data can share or split a same byte. A
byte is the minimum storage unit.

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
43 44
rights reserved. rights reserved.

Output Devices: Monitor Monitor Resolution and Dot Pitch


The monitor displays information (text and graphics). The resolution resolution The screen resolution specifies the number of pixels in
and dot pitch determine the quality of the display. Laptops today horizontal and vertical dimensions of the display device.
often approach or exceed the quality of an high-definition (HD) Pixels (short for “picture elements”) are tiny dots that form
television, which is 1920x1080 pixels, and mobile devices are often an image on the screen. A common resolution for a 17-inch
even better. For example the Samsung Galaxy S7 has a screen with screen, for example, is 1,024 pixels wide and 768 pixels
2560x1440 pixel resolution. high. The resolution can be set manually. The higher the
Bus resolution, the sharper and clearer the image is.

Storage Communication Input Output


Memory CPU Devices Devices Devices
Devices
e.g., Disk, CD, e.g., Modem, e.g., Keyboard, e.g., Monitor, dot pitch The dot pitch is the amount of space between pixels,
and Tape and NIC Mouse Printer
measured in millimeters. The smaller the dot pitch, the
sharper the display.

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
45 46
rights reserved. rights reserved.

Communication Devices Programs


A regular modem uses a phone line and can transfer data in a speed up to
56,000 bps (bits per second). A DSL (digital subscriber line) also uses a
phone line and can transfer data in a speed 20 times faster than a regular
Computer programs, known as software, are instructions to
modem. A cable modem uses the TV cable line maintained by the cable the computer.
company. A cable modem is as fast as a DSL. Network interface card
(NIC) is a device to connect a computer to a local area network (LAN).
The LAN is commonly used in business, universities, and government You tell a computer what to do through programs. Without
organizations. A typical type of NIC, called 10BaseT, can transfer data at programs, a computer is an empty machine. Computers do
10 mbps (million bits per second).
Bus
not understand human languages, so you need to use
computer languages to communicate with them.
Storage Communication Input Output
Memory CPU Devices Devices Devices
Devices
e.g., Disk, CD, e.g., Modem, e.g., Keyboard, e.g., Monitor, Programs are written using programming languages.
and Tape and NIC Mouse Printer

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
47 48
rights reserved. rights reserved.

8
8/22/18

Programming Languages Programming Languages


Machine Language Assembly Language High-Level Language Machine Language Assembly Language High-Level Language

Machine language is a set of primitive instructions Assembly languages were developed to make programming
built into every computer. The instructions are in easy. Since the computer cannot understand assembly
the form of binary code, so you have to enter binary language, however, a program called assembler is used to
convert assembly language programs into machine code.
codes for various instructions. Program with native For example, to add two numbers, you might write an
machine language is a tedious process. Moreover instruction in assembly code like this:
the programs are highly difficult to read and ADDF3 R1, R2, R3
modify. For example, to add two numbers, you
might write an instruction in binary like this:

1101101010011010
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
49 50
rights reserved. rights reserved.

Programming Languages Popular High-Level Languages


Machine Language Assembly Language High-Level Language
Languag e Description

The high-level languages are English-like and easy to learn Ada Named for Ada Lovelace, who worked on mechanical general-purpose computers. The Ada
language was developed for the Department of Defense and is us ed mainly in d efense projects.
and program. For example, the following is a high-level BASIC Beginner’s All-purpose Symbolic Instruction Code. It was d esigned to be learned and used easily
by beginners.
language statement (C, C++, Java, Python) that computes C Developed at Bell Laboratories. C combines the power of an ass embly language with the ease of
the area of a circle with radius 5: C++
use and portability of a high-level language.
C++ is an object-oriented language, based on C.
area = 5 * 5 * 3.1415; C# Pronounced “C Sh arp.” It is a hybrid of Java and C++ and was developed by Microsoft.
COBOL COmmon Business Oriented Language. Used for business applications.
FORTRAN FORmula TRANslation. Popular for scientific and mathematical applications.
Java Developed by Sun Microsystems, now part of Oracle. It is widely used for developing platform -
independent Internet app lications.
Pascal Named for Blaise Pascal, wh o pioneered calculating machin es in the seventeenth century. It is a
simple, s tructured, general -purpose language p rimarily for teachin g programming.
Python A simple gen eral-purpose scripting language good for writing short programs .
Visual Visual Basic was developed by Microsoft and it enables the pr ogrammers to rapidly develop
Basic graphical user interfaces.

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
51 52
rights reserved. rights reserved.

Interpreting/Compiling Source Code Interpreting Source Code


A program written in a high-level language is called An interpreter reads one statement from the source
a source program or source code. Because a code, translates it to the machine code or virtual
computer cannot understand a source program, a machine code, and then executes it right away, as
source program must be translated into machine shown in the following figure. Note that a statement
code for execution. The translation can be done from the source code may be translated into several
using another programming tool called an machine instructions.
interpreter or a compiler.

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
53 54
rights reserved. rights reserved.

9
8/22/18

Compiling Source Code Operating Systems


The operating system (OS) is a
A compiler translates the entire source code into a program that manages and controls
a computer’s activities. The
machine-code file, and the machine-code file is popular operating systems for
then executed, as shown in the following figure. general-purpose computers
are Microsoft Windows, Mac
OS, and Linux. Application
programs, such as a Web
browser or a word processor,
cannot run unless an
operating system is installed
and running on the computer.

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
55 56
rights reserved. rights reserved.

Why Java? Java, Web, and Beyond


The answer is that Java enables users to develop and ✦ Java can be used to develop standalone
deploy applications on the Internet for servers, desktop
applications.
computers, and small hand-held devices. The future of
computing is being profoundly influenced by the Internet, ✦ Java can be used to develop applications
and Java promises to remain a big part of that future. Java running from a browser.
is the Internet programming language. ✦ Java can also be used to develop applications
for hand-held devices.
✦Java is a general purpose programming language. ✦ Java can be used to develop applications for
✦Java is the Internet programming language. Web servers.

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
57 58
rights reserved. rights reserved.

Companion
Java’s History Website Characteristics of Java
✦ Java Is Simple
✦ James Gosling and Sun Microsystems
✦ Java Is Object-Oriented
✦ Oak ✦ Java Is Distributed
✦ Java, May 20, 1995, Sun World ✦ Java Is Interpreted
✦ Java Is Robust
✦ HotJava ✦ Java Is Secure
– The first Java-enabled Web browser ✦ Java Is Architecture-Neutral
✦ Early History Website: ✦ Java Is Portable
✦ Java's Performance
http://www.java.com/en/javahistory/index.jsp ✦ Java Is Multithreaded
✦ Java Is Dynamic
www.cs.armstrong.edu/liang/JavaCharacteristics.pdf
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
59 60
rights reserved. rights reserved.

10
8/22/18

Companion Companion
Website Characteristics of Java Website Characteristics of Java
✦ Java Is Simple Java is partially modeled on C++, but greatly ✦ Java Is Simple Java is inherently object-oriented.
simplified and improved. Some people refer to Although many object-oriented languages
✦ Java Is Object-Oriented ✦ Java Is Object-Oriented
Java as "C++--" because it is like C++ but began strictly as procedural languages,
✦ Java Is Distributed with more functionality and fewer negative ✦ Java Is Distributed Java was designed from the start to be
aspects. object-oriented. Object-oriented
✦ Java Is Interpreted ✦ Java Is Interpreted
programming (OOP) is a popular
✦ Java Is Robust ✦ Java Is Robust programming approach that is replacing
traditional procedural programming
✦ Java Is Secure ✦ Java Is Secure
techniques.
✦ Java Is Architecture-Neutral ✦ Java Is Architecture-Neutral
✦ Java Is Portable ✦ Java Is Portable One of the central issues in software
development is how to reuse code. Object-
✦ Java's Performance ✦ Java's Performance oriented programming provides great
✦ Java Is Multithreaded ✦ Java Is Multithreaded flexibility, modularity, clarity, and
reusability through encapsulation,
✦ Java Is Dynamic ✦ Java Is Dynamic inheritance, and polymorphism.

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
61 62
rights reserved. rights reserved.

Companion Companion
Website Characteristics of Java Website Characteristics of Java
✦ Java Is Simple Distributed computing involves several ✦ Java Is Simple You need an interpreter to run Java
computers working together on a network. programs. The programs are compiled into
✦ Java Is Object-Oriented ✦ Java Is Object-Oriented
Java is designed to make distributed the Java Virtual Machine code called
✦ Java Is Distributed computing easy. Since networking ✦ Java Is Distributed bytecode. The bytecode is machine-
capability is inherently integrated into independent and can run on any machine
✦ Java Is Interpreted ✦ Java Is Interpreted
Java, writing network programs is like that has a Java interpreter, which is part of
✦ Java Is Robust sending and receiving data to and from a ✦ Java Is Robust the Java Virtual Machine (JVM).
file.
✦ Java Is Secure ✦ Java Is Secure
✦ Java Is Architecture-Neutral ✦ Java Is Architecture-Neutral
✦ Java Is Portable ✦ Java Is Portable
✦ Java's Performance ✦ Java's Performance
✦ Java Is Multithreaded ✦ Java Is Multithreaded
✦ Java Is Dynamic ✦ Java Is Dynamic

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
63 64
rights reserved. rights reserved.

Companion Companion
Website Characteristics of Java Website Characteristics of Java
✦ Java Is Simple Java compilers can detect many problems ✦ Java Is Simple
that would first show up at execution time
✦ Java Is Object-Oriented ✦ Java Is Object-Oriented
in other languages.
✦ Java Is Distributed ✦ Java Is Distributed
Java has eliminated certain types of error-
✦ Java Is Interpreted ✦ Java Is Interpreted
prone programming constructs found in Java implements several security
✦ Java Is Robust other languages. ✦ Java Is Robust mechanisms to protect your system against
✦ Java Is Secure ✦ Java Is Secure harm caused by stray programs.
Java has a runtime exception-handling
✦ Java Is Architecture-Neutral feature to provide programming support ✦ Java Is Architecture-Neutral
✦ Java Is Portable for robustness. ✦ Java Is Portable
✦ Java's Performance ✦ Java's Performance
✦ Java Is Multithreaded ✦ Java Is Multithreaded
✦ Java Is Dynamic ✦ Java Is Dynamic

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
65 66
rights reserved. rights reserved.

11
8/22/18

Companion Companion
Website Characteristics of Java Website Characteristics of Java
✦ Java Is Simple ✦ Java Is Simple
✦ Java Is Object-Oriented ✦ Java Is Object-Oriented
✦ Java Is Distributed ✦ Java Is Distributed
✦ Java Is Interpreted ✦ Java Is Interpreted
✦ Java Is Robust ✦ Java Is Robust
✦ Java Is Secure ✦ Java Is Secure
✦ Java Is Architecture-Neutral Write once, run anywhere ✦ Java Is Architecture-Neutral
✦ Java Is Portable ✦ Java Is Portable Because Java is architecture neutral,
With a Java Virtual Machine (JVM),
Java programs are portable. They can
✦ Java's Performance you can write one program that will ✦ Java's Performance be run on any platform without being
run on any platform.
✦ Java Is Multithreaded ✦ Java Is Multithreaded recompiled.
✦ Java Is Dynamic ✦ Java Is Dynamic

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
67 68
rights reserved. rights reserved.

Companion Companion
Website Characteristics of Java Website Characteristics of Java
✦ Java Is Simple ✦ Java Is Simple
✦ Java Is Object-Oriented ✦ Java Is Object-Oriented
✦ Java Is Distributed ✦ Java Is Distributed
✦ Java Is Interpreted ✦ Java Is Interpreted
✦ Java Is Robust ✦ Java Is Robust
✦ Java Is Secure ✦ Java Is Secure
✦ Java Is Architecture-Neutral ✦ Java Is Architecture-Neutral
✦ Java Is Portable Java’s performance Because Java is ✦ Java Is Portable
architecture neutral, Java programs are
✦ Java's Performance portable. They can be run on any ✦ Java's Performance Multithread programming is smoothly
✦ Java Is Multithreaded platform without being recompiled. ✦ Java Is Multithreaded integrated in Java, whereas in other
languages you have to call procedures
✦ Java Is Dynamic ✦ Java Is Dynamic specific to the operating system to enable
multithreading.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
69 70
rights reserved. rights reserved.

Companion
Website Characteristics of Java JDK Versions
✦ Java Is Simple
✦ JDK 1.02 (1995)
✦ Java Is Object-Oriented
✦ Java Is Distributed
✦ JDK 1.1 (1996)
✦ Java Is Interpreted
✦ JDK 1.2 (1998)
✦ Java Is Robust ✦ JDK 1.3 (2000)
✦ Java Is Secure ✦ JDK 1.4 (2002)
✦ Java Is Architecture-Neutral ✦ JDK 1.5 (2004) a. k. a. JDK 5 or Java 5
✦ Java Is Portable ✦ JDK 1.6 (2006) a. k. a. JDK 6 or Java 6
Java was designed to adapt to an evolving
✦ Java's Performance environment. New code can be loaded on the ✦ JDK 1.7 (2011) a. k. a. JDK 7 or Java 7
✦ Java Is Multithreaded fly without recompilation. There is no need for
developers to create, and for users to install, ✦ JDK 1.8 (2014) a. k. a. JDK 8 or Java 8
✦ Java Is Dynamic major new software versions. New features can
be incorporated transparently as needed.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All
71 72
rights reserved. rights reserved.

12

You might also like