1. Introduction to Java.docx
1. Introduction to Java.docx
Java programming language was originally developed by Sun Microsystems which was initiated by James Gosling and
released in 1995 as core component of Sun Microsystems' Java platform (Java 1.0 [J2SE]).
The latest release of the Java Standard Edition is Java SE 8. With the advancement of Java and its widespread popularity,
multiple configurations were built to suit various types of platforms. For example: J2EE for Enterprise Applications, J2ME for Mobile
Applications.
The new J2 versions were renamed as Java SE, Java EE, and Java ME respectively. Java is guaranteed to be Write Once, Run
Anywhere.
1. Classes –A class can be defined as a template/blueprint that describes the behavior/state that the object of its type
supports.
2. Objects – The instances of a class which are used in real functionality, its variables and operations.
3. Abstraction – Specifying what to do but not how to do, a flexible feature for having a overall view of an object’s
functionality.
4. Encapsulation – Binding data and operations of data together in a single unit – A class adhere this feature
5. Inheritance and class hierarchy – Reusability and extension of existing classes.
6. Polymorphism – Multiple definitions for a single name - functions with same name with different functionality; saves time
in investing many function names Operator and Function overloading
7. Generic classes – Class definitions for unspecified data. They are known as container classes. They are flexible and reusable.
8. Class libraries – Built-in language specific classes
9. Message passing – Objects communicates through invoking methods and sending data to them. This feature of sending and
receiving information among objects through function parameters is known as Message Passing.
History of Java:
James Gosling initiated Java language project in June 1991 for use in one of his many set-top box projects. The language,
initially called ‘Oak’ after an oak tree that stood outside Gosling's office, also went by the name ‘Green’ and ended up later being
renamed as Java, from a list of random words.
Sun released the first public implementation as Java 1.0 in 1995. It promised Write Once, Run Anywhere (WORA), providing
no-cost run-times on popular platforms.
Versions of Java:
● JDK 1.0 (January 21, 1996)
● JDK 1.1 (February 19, 1997)
● J2SE 1.2 (December 8, 1998)
● J2SE 1.3 (May 8, 2000)
● J2SE 1.4 (February 6, 2002)
● J2SE 5.0 (September 30, 2004)
● Java SE 6 (December 11, 2006)
● Java SE 7 (July 28, 2011)
● Java SE 8 (March 18, 2014)
Properties of java:
1. Object Oriented: In Java, everything is an Object. Java can be easily extended since it is based on the Object model.
2. Platform Independent: Unlike many other programming languages including C and C++, when Java is compiled, it is not
compiled into platform specific machine, rather into platform independent byte code. This byte code is distributed over the
web and interpreted by the Virtual Machine (JVM) on whichever platform it is being run on.
3. Simple: Java is designed to be easy to learn. If you understand the basic concept of OOP Java, it would be easy to master.
4. Secure: With Java's secure feature it enables to develop virus-free, tamper-free systems. Authentication techniques are
based on public-key encryption.
5. Architecture-neutral: Java compiler generates an architecture-neutral object file format, which makes the compiled code
executable on many processors, with the presence of Java runtime system.
6. Portable: Being architecture-neutral and having no implementation dependent aspects of the specification makes Java
portable. Compiler in Java is written in ANSI C with a clean portability boundary, which is a POSIX subset.
7. Robust: Java makes an effort to eliminate error prone situations by emphasizing mainly on compile time error checking and
runtime checking.
8. Multithreaded: With Java's multithreaded feature it is possible to write programs that can perform many tasks
simultaneously. This design feature allows the developers to construct interactive applications that can run smoothly.
9. Interpreted: Java byte code is translated on the fly to native machine instructions and is not stored anywhere. The
development process is more rapid and analytical since the linking is an incremental and light-weight process.
10. High Performance: With the use of Just-In-Time compilers, Java enables high performance.
11. Distributed: Java is designed for the distributed environment of the internet.
As shown in above diagram, we are having a java file (demo.java) which is also known as a source file. A source file
is basically written in human readable language that means only humans can understand this language, machine won’t.
A source file is passed to the compiler, where compiler converts .java file to a .class file (demo.class). The Class file
is nothing but a byte code which is in machine level language. This conversion is necessary as machine does not understand
the human language, machine only understands binary language which is the form of zero’s and once.
Now, we have .class file which is nothing but a byte code, is further passed to the JVM (Java virtual machine) for
execution. Inside JVM there is a interpreter who is responsible for executing the byte code with the help of java library files.
And after successful execution, user will get the expected results on his screen.
What is JVM?
JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides runtime environment in which
java byte code can be executed. JVM is consisting of interpreter and some library files provided by java. These two are
responsible for executing a byte code.
o Loads code
o Verifies code
o Executes code
o Provides runtime environment
Java is platform independent, but JVM is platform dependent because configuration of each OS differs. JVM is available for
many hardware and software platforms. Compiler converts .java file into byte code. As JVM only understands byte code and there
are different JVM’s for every OS, byte code can be executed anywhere, where the JVM is available. So because of this reason only
java is platform independent.
What is JRE?
JRE is an acronym for Java Runtime Environment. It is used to provide runtime environment. It is the implementation of
JVM. It physically exists. It contains set of libraries plus other files that JVM uses at runtime.
What is JDK?
JDK is an acronym for Java Development Kit. It physically exists. It contains JRE plus development tools which provides a
platform where one can write, compile and execute java code.
If a user does not have JDK installed, he will not be able to execute a java program on his system.