Sie sind auf Seite 1von 9

(PROGRAMMING I)

HO – # 1 (Introduction To Programming)

INTRODUCTION TO JAVA
TOPICS:
 Defining Programming and its importance
 History of Programming
 History of Java
 Features of Java
 Installing Java
 Defining Compiling, Interpreting and Linking

1.1. DEFINING PROGRAMMING AND ITS IMPORTANCE


 Programming is a process that leads from an original formulation of a computing problem to
executable computer programs.
 It involves activities such as:
o Analysis
o developing understanding
o generating algorithms
o verification of requirements of algorithms including their correctness and resources
consumption
o implementation (commonly referred to as coding) of algorithms in a target programming
language.

Why is programming important?


Writing programs gives you the power to control your PC. Almost everyone knows how to use a
computer, but few people take the next step and learn how to control it. If you use other people’s
software, you will always be limited by what other people think you want to do. Write your own
programs and the only limit will be your own imagination. Programming will make you more creative,
it will make you think more precisely, and it will teach you to analyze and solve problems logically.

The Benefits of Programming


 Salary and perks
 Job flexibility
 Programming skills development
 High demand
 Training and development
 Job Security
 Subject knowledge enhancement

1.2. HISTORY OF PROGRAMMING


YEAR INVENTION/ACHIEVEMENT INVENTOR/PROPONENT

2500 BC Abacus Sumerians


100 BC Antikythera Mechanism Greeks
1206 AD Programmable Automata Al-Jazari
1801 Jacquard Loom Joseph Marie Jacquard
1830 Use of Punched Cards to control the Analytical Engine Charles Babbage
1842- 1843 Notes and an Algorithm to calculate a sequence of Lady Ada Lovelace
Bernoulli Numbers
1880 Hollerith’s Tabulating Machine Herman Hollerith
1896 Founding of the Tabulating Machine Company (now Herman Hollerith
known as IBM)

Page 1 of 9
(PROGRAMMING I)
HO – # 1 (Introduction To Programming)
1.3. LEVELS OF PROGRAMMING LANGUAGES
a) Absolute Machine Code
The very lowest possible level at
which you can program a computer
is in its own native machine code,
consisting of strings of 1's and 0's
and stored as binary numbers.

Fig. 1 Machine Code consisting of 1’s and 0’s

b) Assembly Language
Assembly language is nothing more
than a symbolic representation of
machine code, which also allows
symbolic designation of memory
locations.

Fig. 2 Assembly Languages consisting of


instruction sets

c) Compiler Language
Compiler languages are the high-
level equivalent of assembly
language. Each instruction in the
compiler language can correspond to
many machine instructions. Once
the program has been written, it is
translated to the equivalent machine
code by a program called a compiler.
Once the program has been
compiled, the resulting machine
code is saved separately, and can be Fig. 3 A source code in Java consisting of
run on its own at any time. syntaxes or statements. This is a program that is
compiled into ByteCode.
d) Interpreter Language
An interpreter language, like a
compiler language, is considered to
be high level. However, it operates in
a totally different manner from a

Page 2 of 9
(PROGRAMMING I)
HO – # 1 (Introduction To Programming)
compiler language. Rather, the
interpreter program resides in
memory, and directly executes the
high-level program without
preliminary translation to machine
code.

1.4. HISTORY OF JAVA


 Java was created in 1991 by James Gosling et al. of Sun Microsystems.
 Initially called Oak, in honor of the tree outside Gosling's window, its name was changed to Java
because there was already a language called Oak.
 Java sought to answer the need for platform independent language that could be embedded in
various consumer electronic products like toasters and refrigerators.
 At about the same time, the World Wide Web and the Internet were gaining popularity. Gosling et.
al. realized that Java could be used for Internet programming.

1.5. FEATURES OF JAVA


a. Simple
Java is easy to learn and its syntax is quite simple, clean and easy to understand.
b. Object Oriented
In java everything is Object which has some data and behaviour. Java can be easily extended as it
is based on Object Model.
c. Robust
Java makes an effort to eliminate error prone codes by emphasizing mainly on compile time error
checking and runtime checking.
d. Platform Independent
Unlike other programming languages such as C, C++, etc. which are compiled into platform
specific machines. Java is guaranteed to be write-once, run-anywhere language.
e. Secure
With java secure features it enable us to develop virus free, temper free system. Java program
always runs in Java runtime environment with almost null interaction with system OS, hence it is
more secure.
f. Multi-Threading
Java multithreading feature makes it possible to write program that can do many tasks
simultaneously. Benefit of multithreading is that it utilizes same memory and other resources to
execute multiple threads at the same time, like While typing, grammatical errors are checked
along.
g. Architectural Neutral
Compiler generates bytecodes, which have nothing to do with a particular computer architecture,
hence a Java program is easy to intrepret on any machine.
h. Portable
Java Byte code can be carried to any platform. No implementation dependent features. Everything
related to storage is predefined, example: size of primitive data types
i. High Performance
Java is an interpreted language, so it will never be as fast as a compiled language like C or C++.
But, Java enables high performance with the use of just-in-time compiler.
Source: http://www.studytonight.com/java/features-of-java.php

1.6. INSTALLING JAVA


To make software in Java, one must complete two important steps:
a. Install the Java Development Kit (JDK)
a.1. Open up a browser.
a.2. In the search bar, type the keyword “Java”

Page 3 of 9
(PROGRAMMING I)
HO – # 1 (Introduction To Programming)
a.3. You will be given a list of search results. Click the link that has the following web address:

a.4. On the Java Downloads page, click the Red button with the label “Free Java Download”.
Then, notice at the bottom (Google Chrome) that the download will start. This is the JDK
installer and should Chrome ask you “Do you want to keep the file?” Click “Yes”

Click the downloaded file (“JavaSetup8u101.exe”)

a.5. A window such as this will open (but before that you must select “Yes” to the “Do you want
this program to make changes to this computer?”).
Then, on this window click “Install”.

Page 4 of 9
(PROGRAMMING I)
HO – # 1 (Introduction To Programming)
a.7. Then, the computer shall download the installer of Java. Wait for the progress bar (the green
one) to complete.

a.8. Then, once the installer has been downloaded, this window will appear. Again, wait patiently
for the JDK to install itself.

a.9. After the successful installation of the JDK, this window will appear. Click the “Close”
button.

Page 5 of 9
(PROGRAMMING I)
HO – # 1 (Introduction To Programming)
b. Then, after you have finished downloading the JDK, it’s time for us to choose our editor. In
this case, we shall use the Eclipse IDE.
b.1. Type “Eclipse IDE” on the Search Bar.
b.2. Wait for the page to load. Search and click the link that looks like this:

b.3. Scroll down a little bit. Then, select the “Download Packages” link.

b.4. Select the 32-bit installer. Click the “32 bit” link. Again, click the “Download” button.

b.5. The download will start. Wait for the download to finish.
b.6. Click the downloaded file to run the installer.

b.7. Select “Eclipse IDE for Java Developers”.

Page 6 of 9
(PROGRAMMING I)
HO – # 1 (Introduction To Programming)

b.8. Click “Install”.


b.9. Click the “Accept” button.

b.10. The installation will start. Wait for it to finish. Then click “Close”

1.7. DEFINING COMPILING, INTERPRETING AND LINKING


HOW IS A PROGRAM CREATED?

a. Compiling
A compiler is a computer program (or a set of programs) that transforms source code written in
a programming language (the source language) into another computer language (the target
language), with the latter often having a binary form known as object code. The most common
reason for converting source code is to create an executable program.

b. Linking
Linking refers to the creation of a single executable file from multiple object files.

Page 7 of 9
(PROGRAMMING I)
HO – # 1 (Introduction To Programming)

c. Interpreting
With computer programming, interpreted or an interpreted language refers to a language that
does not need to be compiled before it is executed. However, because the script or program is not
compiled, it requires an interpreter to run.
An interpreter takes the script or program code and modifies it in such a way that it can be
understood and the executed by the computer.

DIFFERENCE OF COMPILER AND INTERPRETER:


• The basic difference between the compiler and the interpreter is that compiler converts the
program to machine code while interpreter reads the source code and executes it instead of
creating a machine code.
• In the compiled language the machine code is executed while in iterpreted languages the
source code itself is executed with the help of interpreter i.e.

compiler + source code = machine code


execute machine code = output
interpreter + source code = output

HOW IS JAVA PROGRAM CREATED, COMPILED AND RUN?

POWERFUL FEATURES OF JAVA


a. The Java Virtual Machine
● Java Virtual Machine (JVM)
– an imaginary machine that is implemented by emulating software on a real machine
● Bytecode
– independent of any particular computer hardware, so any computer with a Java
interpreter can execute the compiled Java program, no matter what type of computer
the program was compiled on

b. Garbage Collection
● Garbage collection thread
– responsible for freeing any memory that can be freed. This happens automatically
during the lifetime of the Java program.

Page 8 of 9
(PROGRAMMING I)
HO – # 1 (Introduction To Programming)
c. Code Security
● Code security is attained in Java through the implementation of its Java Runtime
Environment (JRE).
● JRE
– runs code compiled for a JVM and performs class loading (through the class loader),
code verification (through the bytecode verifier) and finally code execution
● Class Loader
– Responsible for loading all classes needed for the Java program
– adds security by separating the namespaces for the classes of the local file system
from those that are imported from network sources

● Bytecode verifier
– tests the format of the code fragments and checks the code fragments for illegal code
that can violate access rights to objects

Page 9 of 9

Das könnte Ihnen auch gefallen