INTRODUCTION AND
HISTORY OF JAVA
JAMES GOSLING - The creator of Java
Sun Microsystems – an internal corporate
who funded the research project codename
GREEN in 1991.
OAK – first name of Java after an oak tree
that stood outsides the creators office.
It was learned that there is already a
language called OAK.
It was change to JAVA (coffee).
Therewere some difficulties encountered by
the Green project in the early 1990’s and
was in danger of being canceled.
With
the help of WWW, Sun people saw the
need to add dynamic content using JAVA.
Interactivity
and Animation were added to
the web pages.
JAVA is the programming language of
choice for applying Internet-based phones
applications and software for devices that
connect over a network.
Portability and Security – essential key
that dictated the creation of the language.
FEATURES OF JAVA
OBJECT-ORIENTED
DYNAMIC
MULTI-THREADED
ARCHITECTURE-NEUTRAL
FEATURES OF JAVA
OBJECT-ORIENTED
Java is an object-oriented programming language.
Object-oriented means we organize our software as a
combination of different types of objects that
incorporates both data and behavior.
FEATURES OF JAVA
OBJECT-ORIENTED
Basic concepts of OOPs are:
Object
Class
Inheritance
Polymorphism
Abstraction
Encapsulation
FEATURES OF JAVA
DYNAMIC
Java is a dynamic language. It supports dynamic loading
of classes. It means classes are loaded on demand. It also
supports functions from its native languages, i.e., C and
C++.
FEATURES OF JAVA
MULTI-THREADED
A thread is like a separate program, executing
concurrently. We can write Java programs that deal
with many tasks at once by defining multiple threads.
The main advantage of multi-threading is that it
doesn't occupy memory for each thread. It shares a
common memory area. Threads are important for
multi-media, Web applications, etc.
FEATURES OF JAVA
ARCHITECTURE-NEUTRAL
Javais architecture neutral because there are no
implementation dependent features, for example,
the size of primitive types is fixed.
FIVE PHASES
Create/Edit
Compile
Load
Verify
Excute
PHASE 1: Create/Edit
Creating and editing a file using an editor is
done by the programmer. This is where the
programmer types the needed rectifications
and save the program on a storage device
as .java file extension.
PHASE 2: Compile
The Java command is used by the
programmer to compile a program. In this
phase, if you are going to compile a program
called Greeting.java, you would type:
Javac Greeting.java
PHASE 3: Load
Before loading is performed, the
programmer will have to place the program
in the memory before it can implement a
process. The .class files containing the
program’s byte codes will be taken by the
class loader and transmits it to memory.
PHASE 4: Verify
Byte codes are examined by the byte code
verifier to validate that it does not defy Java
restrictions. It ensures that Java programs
entering over the network does not harm the
user’s files or system.
PHASE 5: Execute
The byte codes stated in the program will be
executed by the JVM. As they are
interpreted, JVM analyses the byte codes.
Sample Java program
1. // Program that print a text
2. public class Welcome
3. {
4. public static void main (String args[])
5. {
6. System.out.println(“Hello World”);
7. }
8. }
Line 1 - // indicates comment lines. This is where the
user/programmer can insert documentation used to improve
readability. Items enclosed in /* and */ also denotes
comments
Line 2 – This is a class declaration for class Welcome. Java programs
must have at least one class declaration that is defined.
Line 3 – A left brace indicates the beginning of the body of a class
declaration.
Line 4 – This shows the starting point of a Java application. Items
enclosed in parentheses indicates that it is a program building
block called method.
Line 5 – This left brace starts the body of the method.
Line 6 – This directs the computer to do an action.
Line 7 – This right brace must end the method declaration body.
Line 8 – This right brace ends class declaration