0% found this document useful (0 votes)
22 views

Ch. 1 - Lecture 2 - Program Development

The document provides instructions for installing Java on a Windows machine by downloading and running an installation file, setting the PATH environment variable to include the Java bin directory, and testing the installation by running java commands. It also describes setting the CLASSPATH variable and explains how to check if Java is correctly installed by opening a command prompt and typing "java".

Uploaded by

elio saliba
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Ch. 1 - Lecture 2 - Program Development

The document provides instructions for installing Java on a Windows machine by downloading and running an installation file, setting the PATH environment variable to include the Java bin directory, and testing the installation by running java commands. It also describes setting the CLASSPATH variable and explains how to check if Java is correctly installed by opening a command prompt and typing "java".

Uploaded by

elio saliba
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 19

Installing Java on a Home

machine
 For Windows Users:
Download/Install:
Go to
 http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u31-
download-1501634.html

Accept License Agreement and then download the file named “jdk-6u31-
windows-i586.exe”.
Save the file to the desktop and run it.

The installer will install Java to:


C:\Program Files\Java\jdk1.6.0_31\

Once the installer is finished, you must set your computer's path before
Java will work correctly.
Installing Java on a Home
machine (cont’d)
 Setting the Path:
Go to the Control Panel and double-click System
Select the Advanced tab
Click on the Environment Variables button
Look under System Variables for "Path"
Click on "Path" and then click edit
Add the following to the end of the Path
; C:\Program Files\Java\jdk1.6.0_31\bin
Click OK.
Click the "New" button.
For the variable name, type: CLASSPATH
For the value, type: .;
NOTE: The above value in words is period semicolon; it is not a misprint.
Click OK.
Exit out of all the open windows
Installing Java on a Home
machine (cont’d)
 To test if java is installed correctly:

Open up a command prompt


To do this click on Start and then Run
Type in cmd.exe and click Ok
Type java and hit enter
If you see something like "command not found", then java is not
installed correctly
Otherwise you should see a list of
options for running java
Developing a programming
skill
 Learning to program a computer
 Training yourself to solve problems
 in a very detailed and organized manner

 You are already experienced in


 Intuitive problem solving

 Need to develop programming skill


 Write a problem solution

 IN terms of actions appropriate for a computer


Computer organization
 Computer system
 Hardware
 physical, tangible pieces such as chips, wires, and so on

 Useless without instructions to tell them what to do

 Driven by a series of instructions, in other words programs

 Software
 Programs and the data those programs use

 Intangible counterpart to the physical hardware components


Computer hardware
 Most computer have four major hardware parts
 Central Processing Unit (CPU):
 brain of the computer

 executes individual commands of a program

 Input/output devices
 allow human beings to interact with a computer

 Memory
 stores programs and data while being processed by CPU
Computer hardware (cont’d)

Memory

Input devices Output devices

CPU
What is programming
 Computers performs tasks
 more efficiently, quickly, and accurately

 than we could by hand

 However, to be useful it must be programmed

 Computer programming:
 Devise a set of instructions
 to be executed by a computer

 In order to solve a given real world problem


How do we write a program?
 It is a two phase process

Problem-Solving Implementation
Phase Phase

Analysis and
specification Concrete
solution
General (Program)
solution
(Algorithm) Test
Verify

Maintenance
Phase
Algorithm implementation

JAVA code Peter’s JAVA code

Algorithm C++ code Algorithm Nell’s JAVA code

Ada code John’s JAVA code

Algorithm translated into Algorithm translated by


different languages different people
Programming shortcut

Problem Solving
Phase
Problem (Algorithm)

Shortcut?
Implementation
Phase
(code)

Think first and code later


JAVA program execution
 convert Java code to a form usable by computers
 provided that in a computer instructions and data
 are stored in the computer memories using binary codes

 In a computer,
 data represented by pulses of electricity
 On circuit => ‘1’; Off circuit => ‘0’

 Data in binary form => combination of enough 1s and 0s

 Program execution means


 translating data and instructions to patterns of 1s and 0s.
Programming language levels
 Machine language
 Primitive instruction built into each machine

 Each type of CPU has its own language

 Binary based instructions


 => tedious process and prone to error

 Assembly language
 Short English like words for commands and data

 Tedious to use

Both are considered to be low level languages


Programming language levels
(cont’d)
 High level language
 Expressed in English like phrases

 Easier to read and write


High level Assembly Machine
Language Language Language
a+b ld [%fp-20] %o0 1101 000
0000 0111
ld [%fp-20] %o1 1101 0010
0000 0111
add %o0, %o1 1011 1111
1110 1000
Program development
 Software tools involved
 Editor: type a program and store in a file

 Translation from high level into executable form


 That translation may result in errors

 You change the code to fix the problem

 Execute the program and evaluate results


errors errors

Edit and save Translate Execute


program program program
Compilers
 Translation into machine language
 Compiler:
 Translates code in one language
 to equivalent code in another one

 Original code => source code,

 Target language => particular machine language

 Translate once and run whenever needed


Interpreters
 Translation into machine language
 Interpreter
 similar to compiler with some differences

 Interweaves the translation and execution

 Parts of the source code


 are translated and executed one at a time

 Drawback:
 Programs run more slowly,

 as translation occurs during execution


JAVA translation and
execution
 The process
 combines the use of a compiler and interpreter
 Java source code -> Bytecode (Java compiler)

 JAVA virtual machine reads bytecode and executes it

 Difference between Bytecode and machine language


 Bytecode is not tied to any particular processor type
 It makes JAVA architecture neutral => portable
JAVA translation and
execution (cont’d)

JAVA
Source code

JAVA
JAVA compiler bytecode

JAVA Bytecode
interpreter compiler

Machine
code

You might also like