Chapter 1 - Introduction To Java Language
Chapter 1 - Introduction To Java Language
Chapter 1 - 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.
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.
v. Security manager
It determines what resources a class can access such as reading and writing to the local disk.
5. Robust
• 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
• 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.
1. Standalone Applications
2. Web Applications
3. Enterprise Applications
4. Mobile 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.
• 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
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.