You are on page 1of 14

CHAPTER ONE

INTRODUCTION TO JAVA LANGUAGE

Areas to be covered:

 History of java
 Features of java
 Java Editions
 Types of java programs
What is Java
• Java is a programming language and a platform. Java is a high level, robust, object-oriented and secure programming
language.

History of Java – The Story Behind


• Java was developed by Sun Microsystems (which is now the subsidiary of Oracle)
in the year 1995. James Gosling is known as the father of Java. Before Java, its
name was Oak. Since Oak was already a registered company, so James Gosling
and his team changed the Oak name to Java.
• Choice of name: Java is an island of Indonesia where the first coffee was produced
(called java coffee). It is a kind of espresso bean. Java name was chosen by James
Gosling while having coffee near his office. The engineering team at Sun (called
‘the Green Team’) agreed to this.
• Java was originally designed for interactive television – Mr. Gosling and The Green
Team initiated this project to develop a language for digital devices such as set-
top boxes, televisions, etc. but it was too advanced technology for the digital
cable television industry at the time.
• However, it was best suited for internet programming. Therefore later, Java
technology was incorporated by Netscape.
History of Java – The Story Behind...(Continued)
• In 1995, Time magazine called Java one of the Ten Best
Products of 1995.

Java Versions History


• After the first release of Java, there have been many additional
features added to the language.
• Many java versions have been released till now. The current
stable release of Java is Java SE 10.

1. JDK Alpha and Beta (1995). 9. Java SE 7 (28th July 2011)


2. JDK 1.0 (23rd Jan 1996) 10. Java SE 8 (18th Mar 2014)
3. JDK 1.1 (19th Feb 1997) 11. Java SE 9 (21st Sep 2017)
The Green Team
4. J2SE 1.2 (8th Dec 1998) 12. Java SE 10 (20th Mar 2018)
• Now Java is being used in Windows applications, Web 5. J2SE 1.3 (8th May 2000)
applications, enterprise applications, mobile 6. J2SE 1.4 (6th Feb 2002)
applications, cards, etc. Each new version adds the 7. J2SE 5.0 (30th Sep 2004)
new features in Java. 8. Java SE 6 (11th Dec 2006)
Features of Java
• The primary objective of Java programming language creation was to make it
portable, simple and secure programming language.
• Apart from this, there are also some excellent features which play an
important role in the popularity of this language. The features of Java are also
known as java buzzwords.
• A list of most important features of Java language is given below.

1. Simple
2. Object-Oriented
3. Portable
9. High Performance
4. Platform independent 10. Multithreaded
5. Secured 11. Distributed
12. Dynamic
6. Robust
7. Architecture neutral
8. Interpreted
Features of Java…Continued
1. Simple
• easy to learn; its syntax is simple, clean and easy to understand. According to Sun, Java language is a simple programming
language because:
i. Java syntax is based on C++ (so easier for programmers to learn it after C++).
ii. Java has removed many complicated and rarely-used features, for example, explicit pointers, operator overloading,
etc.

2. Object Oriented
• Just like C++, Java has all the features of an object oriented language: use of classes and objects, encapsulation, inheritance,
polymorphism and abstraction

3. Platform Independent
• Java is a “write once, run anywhere” language. A program developed in Java can be executed on any platform (a platform is
the hardware or software environment/configuration of a device)
• There are two types of platforms: software-based and hardware-based.
• Java provides a software-based platform, meaning that Java programs can run on any machine with any software
configuration.
Features of Java…Continued
• The Java platform has two main components that make programs written on it to be able to run on any other platform:
i. Runtime Environment – that allows Java program to run on any device it is installed. Because of this, Java code can
be run on multiple platforms, for example, Windows, Linux, Sun Solaris, Mac/OS, etc. (How? Basically, when you run
the Java program on a different machine of a different platform, the JRE compiles the Java code and converts it into
bytecode. This bytecode is a platform-independent code hence it can then run on multiple platforms, i.e., Write
Once and Run Anywhere(WORA).
ii. API(Application Programming Interface) – that allows Java programs to run a consistent interface on any device it is
installed, just as the interface would appear on the original machine the program was developed.

4. Secured
Java is best known for its security. With Java, we can develop virus-
free systems. Java is secured because:
i. No explicit pointer – meaning the reference/location of
data in a variable cannot be pin pointed externally.
ii. Java Programs run inside a virtual machine sandbox –
meaning that the Java program does not interact with the
OS directly like other programs, but through the Java
Virtual Machine (JVM, Java’s Runtime Environment).
Viruses and hacks mostly happen at OS level, which means
that Java code is shielded by its runtime environment, the
JVM, as shown in the picture ->
Features of Java…Continued
iii. Classloader
It’s a software component inside the JRE/JVM which when the Java program is run, it separates the package
for the classes of the local file system from those that are imported from network sources, hence local class
files are protected from any malware intrusion loaded from outside, through a network.

iv. Bytecode verifier


When the Java program is compiled and converted to bytecode, it checks the code fragments for illegal code
that can violate access right to objects.

v. Security manager
It determines what resources a class can access such as reading and writing to the local disk.

5. Robust

Robust simply means strong. Java is robust because:


i. It uses strong memory management.
ii. There is a lack of pointers that avoids security problems.
iii. There is automatic garbage collection in java which runs on the Java Virtual Machine to get rid of objects which are
not being used by a Java application anymore.
Features of Java…Continued
6. 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.

7. Portable

• Java is portable because it facilitates you to carry the Java bytecode to any platform. It doesn't require any
implementation.

8. 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 (high level) language that is why it is
slower in compiling than compiled languages, e.g., C, C++, etc. However, when the program is finally compiled/loaded, all
the features can be opened or used fast and with ease.
Features of Java…Continued
9. Distributed

• Java is distributed because it facilitates users to create distributed applications in Java. RMI and EJB are used for creating
distributed applications (applications that can run on different devices at the same time, e.g. ATM).
• The concept of client-server machines – hence parts of a program or the whole program can be accessed from any
machine on the internet or in a local network.

10. 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.
• Multiple threads of different components of a program can be loaded concurrently hence a Java program can be doing
different tasks at the same time.
• Also only the threads of the features being used are loaded, hence memory efficient.
Features of Java…End
11. Dynamic

• Java 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++.
• Java supports dynamic compilation and automatic memory management (garbage collection).

12. Interpreted

Java is a high level language, which makes coding easy since the code semantics is in simple relatable English. E.g. utility is
represented by the keyword ‘util’, displaying a line on screen is represented by ‘println’, etc.

The disadvantage of this, however, is


to o s low.
that during compilation, a Java program is running
is heavyweight hence may be a little pro gram Oops, Sorry!
My
slow, depending on the separate
performance (CPU, RAM, Cache) of your
machine. The lower the specs of your
machine, the slower it will take to
compile and run a Java program.
(Recommended: at least 4GB RAM,
1.86Ghz processor)
Types of Java Programs/Applications
There are mainly 4 types of applications that can be created using Java programming:

1. Standalone Applications
2. Web Applications
3. Enterprise Applications
4. Mobile Applications

1. Standalone Applications 2. Web Applications

• Also known as desktop applications or window-based • An application that runs on the server side and
applications. creates a dynamic page is called a web application.
• These are traditional software that we need to install on every • Currently, Servlet, JSP, Struts, Spring, Hibernate, JSF,
machine and don’t need network connectivity for its etc. technologies are used for creating web
resources to be loaded. applications in Java.
• Examples: Media player, antivirus, etc.
• AWT and Swing are used in Java for creating standalone
applications.

NB: We shall focus on only stand alone applications in this


syllabus
Types of Java Programs/Applications…End
3. Enterprise Applications

• An application that is distributed in nature, such as banking applications, etc. is called enterprise application. It has
advantages of the high-level security, load balancing, and clustering.
• In Java, EJB is used for creating enterprise applications.

4. Mobile Applications

• An application which is created for mobile devices is called a mobile application.


• Currently, Android and Java ME are used for creating mobile applications.
Java Platforms/Editions
There are 4 platforms or editions of Java:

1. Java SE (Java Standard Edition) – used to develop Java stand alone applications

2. Java EE (Java Enterprise Edition) – It is an enterprise platform which is mainly used to develop web and enterprise
applications.

3. Java ME (Java Micro Edition) – It is a micro platform which is mainly used to develop mobile applications.

4. JavaFX – It is used to develop rich internet applications. It uses a light-weight user interface API.

You might also like