Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Chap1introduction To Java

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

Introduction to JAVA

Java is an Object Oriented Programming Language.


History of JAVA:
In 1991, a Group of Sun Engineers (Patrick Naughton & James
Gosling) wanted to design a computer language used to write
programs for consumer electronic devices.
These devices do not have lot of power or memory,
So,The language had to be small & generate very tight code.
Also,Different manufacturer may choose different CPU.
So,It was important that the language is independent of CPU
architecture.This project was named as “Green”.
Accordingly,
The Sun team constructs a model that generates an
intermediate code.
Then,
This intermediate code could be used on any machine
that had the correct interpreter.
The model is called as JVM (Java Virtual Machine).
The Sun peoples are come from UNIX background.
So,
Their new language based on C++ i.e. Object Oriented
James Gosling decided to call this language as “Oak”.
But later,
The team realized that Oak was the name of an existing
language,
So They changed the name to “JAVA”.
In 1992,
The Green project delivered its first version, called “*7
Unfortunately No one was interested in producing this device at sun
And Also,
No any standard consumer electronics companies were
interested in it.
The team spends all 1993 and half 1994 looking for people to
buy its technology. But no one found.
During same period,
The World Wide Web (WWW) part of Internet was growing
bigger and bigger.
The key to this web is “Browser” that translates the hypertext page to
web screen.
In 1994,
Gosling Team realized that they could build a browser that needs
some things to be wired
i.e.
Architecture Neutral,
Real Time, Reliable,
and Secure.
So,
Patrick Naughton & Team build the browser known as
“HotJava” browser.
This browser was written in Java to show the power of Java.
This browser also had Power of Applet and it is capable of executing
code inside web pages.

FEATURES OF JAVA (BUZZWORDS):


1) Simple
2) Object Oriented
3) Distributed
4) Reliable or Robust
5) Secure
6) Architecture Neutral
7) Portable
8) Interpreted
9) High Performance
10) Multithreaded
11) Dynamics
Simple

Java is very easy to learn, and its syntax is simple, clean and easy to
understand. According to Sun Microsystem, Java language is a simple
programming language because:

o Java syntax is based on C++ (so easier for programmers to learn


it after C++).
o Java has removed many complicated and rarely-used features,
for example, explicit pointers, operator overloading, etc.
o There is no need to remove unreferenced objects because there
is an Automatic Garbage Collection in Java.

Object-oriented

Java is an object-oriented programming language. Everything in Java


is an object. Object-oriented means we organize our software as a
combination of different types of objects that incorporate both data
and behavior.

Object-oriented programming (OOPs) is a methodology that


simplifies software development and maintenance by providing some
rules.

Basic concepts of OOPs are:

1. Object
2. Class
3. Inheritance
4. Polymorphism
5. Abstraction
6. Encapsulation

Platform Independent
Java is platform independent because it is different from other
languages like C, C++, etc. which are compiled into platform specific
machines while Java is a write once, run anywhere language. A
platform is the hardware or software environment in which a program
runs.

There are two types of platforms software-based and hardware-based.


Java provides a software-based platform.

The Java platform differs from most other platforms in the sense that
it is a software-based platform that runs on top of other hardware-
based platforms. It has two components:

1. Runtime Environment
2. API(Application Programming Interface)

Java code can be executed on multiple platforms, for example,


Windows, Linux, Sun Solaris, Mac/OS, etc. Java code is compiled by
the compiler and converted into bytecode. This bytecode is a
platform-independent code because it can be run on multiple
platforms, i.e., Write Once and Run Anywhere (WORA).

Secured
Java is best known for its security. With Java, we can develop virus-
free systems. Java is secured because:

o No explicit pointer
o Java Programs run inside a virtual machine sandbox

o Classloader: Classloader in Java is a part of the Java Runtime


Environment (JRE) which is used to load Java classes into the
Java Virtual Machine dynamically. It adds security by
separating the package for the classes of the local file system
from those that are imported from network sources.
o Bytecode Verifier: It checks the code fragments for illegal code
that can violate access rights to objects.
o Security Manager: It determines what resources a class can
access such as reading and writing to the local disk.

Java language provides these securities by default. Some security can


also be provided by an application developer explicitly through SSL,
JAAS, Cryptography, etc.

Robust

The English mining of Robust is strong. Java is robust because:


o It uses strong memory management.
o There is a lack of pointers that avoids security problems.
o Java provides automatic garbage collection which runs on the
Java Virtual Machine to get rid of objects which are not being
used by a Java application anymore.
o There are exception handling and the type checking mechanism
in Java. All these points make Java robust.

Architecture-neutral

Java is architecture neutral because there are no implementation


dependent features, for example, the size of primitive types is fixed.

In C programming, int data type occupies 2 bytes of memory for 32-


bit architecture and 4 bytes of memory for 64-bit architecture.
However, it occupies 4 bytes of memory for both 32 and 64-bit
architectures in Java.

Portable

Java is portable because it facilitates you to carry the Java bytecode to


any platform. It doesn't require any implementation.

High-performance

Java is faster than other traditional interpreted programming


languages because Java bytecode is "close" to native code. It is still a
little bit slower than a compiled language (e.g., C++). Java is an
interpreted language that is why it is slower than compiled languages,
e.g., C, C++, etc.

High-performance

Java is faster than other traditional interpreted programming


languages because Java bytecode is "close" to native code. It is still a
little bit slower than a compiled language (e.g., C++). Java is an
interpreted language that is why it is slower than compiled languages,
e.g., C, C++, etc.
JAVA DEVELOPMENT KIT (JDK):
The Java Development Kit (JDK) is a Sun Microsystems
product for Java developers.
The primary components of the JDK are a selection of
programming tools, like…
java: - The loader for Java applications.
This tool is an interpreter and can interpret the class
files generated by the javac compiler.
javac: - The compiler, which converts source code into Java
bytecode.
jar: - The archiver, which packages related class libraries
into a single JAR file. This tool also helps managing jar
files (archived java class files).
The JDK also contains complete Java Runtime Environment.
It contains JVM and all of the class libraries.
JAVA VIRTUAL MACHINE (JVM):
A Java Virtual Machine (JVM) is a set of software programs
and data structures which used for the execution of other
computer programs and scripts.
The model used by a JVM accepts a form of computer
intermediate language commonly referred to as Java bytecode.
JVM operate on Java bytecode, generated from Java source
code.
JVM can also be used to implement programming languages
other than Java.
The JVM is a crucial component of the Java Platform.
The use of the same bytecode for all platforms allows Java to be
described as "compile once, run anywhere“.
The Java Virtual Machine Specification defines an abstract machine
or processor.
Once a Java virtual machine has been implemented for a given
platform, any Java program (which, after compilation, is called
bytecode) can run on that platform.
A Java virtual machine can either interpret the bytecode one
instruction at a time (mapping it to a real processor instruction)
Or
The bytecode can be compiled further for the real processor
using what is called a just-in-time compiler.

You might also like