0% found this document useful (0 votes)
113 views20 pages

Introduction To Java

Java was developed by James Gosling at Sun Microsystems in 1995. It is a widely used programming language that is platform-independent, object-oriented, and designed for distributed computing. There are four main types of Java applications: standalone applications, web applications, enterprise applications, and mobile applications. The Java platform includes Java SE for core programming, Java EE for enterprise applications, and Java ME for mobile applications.

Uploaded by

Udayraj Dhavande
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
113 views20 pages

Introduction To Java

Java was developed by James Gosling at Sun Microsystems in 1995. It is a widely used programming language that is platform-independent, object-oriented, and designed for distributed computing. There are four main types of Java applications: standalone applications, web applications, enterprise applications, and mobile applications. The Java platform includes Java SE for core programming, Java EE for enterprise applications, and Java ME for mobile applications.

Uploaded by

Udayraj Dhavande
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 20

Introduction to Java

Java

 Developed by James Gosling at Sun Microsystems.

 Introduced in 1995.

 Is one the fastest growing programming


technologies of all time.

 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.

 The acquisition of Sun Microsystems by Oracle


Corporation was completed on January 27, 2010.
What is Java

Java is a widely used programming language and is designed


for the distributed environment of internet. It is a general-
purpose programming language that is concurrent, class-based, and
object-oriented.
It is free to access and we can run it on all the platforms.
Java follows the principle of WORA (Write Once, Run Anywhere),
and is platform-independent. It is also simple and easy to learn.

Platform: Any hardware or software environment in which a program


runs, is known as a platform. Since Java has a runtime
environment (JRE) and API, it is called a platform.

Simply a platform = processor + Operating System


Types of Java Applications

There are mainly 4 types of applications that can be created using


Java programming:

1) Standalone Application
Standalone applications are also known as desktop applications
or window-based applications. These are traditional software that
we need to install on every machine. Examples of standalone
application are Media player, antivirus, etc. AWT and Swing are
used in Java for creating standalone applications.

2) Web Application
An application that runs on the server side and creates a
dynamic page is called a web application.
Currently, Servlet, JSP, Struts, Spring, Hibernate, JSF, etc.
technologies are used for creating web applications in Java.
Types of Java Applications
3) Enterprise Application
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 Application
An application which is created for mobile devices is called a
mobile application. Currently, Android and Java ME are used for
creating mobile applications.

Embedded System
Smart Card
Robotics
Games, etc.
Java Platform Editions
1) Java SE (Java Standard Edition)
It is a Java programming platform. It includes Java programming APIs such as
java.lang, java.io, java.net, java.util, java.sql, java.math etc. It includes
core topics like OOPs, String, Regex, Exception, Inner classes, Multithreading,
I/O Stream, Networking, AWT, Swing, Reflection, Collection, etc.

2) Java EE (Java Enterprise Edition)


It is an enterprise platform which is mainly used to develop web and
enterprise applications. It is built on the top of the Java SE platform. It
includes topics like Servlet, JSP, Web Services, EJB, JPA, etc.

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.
Features of Java Programming
1. Simple
While Java is verbose, its syntax is similar to C++. This makes it easier
to transition from C++ to Java. It has removed rarely-used features like
operator overloading and explicit pointers. There is no need to remove
unreferenced objects because there is an Automatic Garbage Collection in
Java.
2. Object-oriented
Java mainly focuses on objects rather than processes. Java follows the
principles of Object-Oriented Programming (OOP):
• Objects
• Classes
• Inheritance
• Encapsulation / Data hiding
• Abstraction
• Polymorphism
Note- Java isn’t a purely object-oriented language as it allows primitive data
types
3. Platform-independent
Platform independent means that the java source code can run on
multiple operating systems. Java code should run on any machine that
doesn’t need any special software to be installed, yet the JVM needs
to be present in the machine. Java code is compiled into bytecode,
which is platform-independent. You can run it on Windows, Linux, Mac
OS, etc.
platform = processor + Operating System
4. Portable
Java is portable because Java code can be executed on all the
major platforms. Once you’ve compiled your Java source code to
bytecode, those files can be used on any Java-supported platform
without modification, unlike other languages, which requires
compiling the machine code for each platform, for example, a separate
.exe for 32-bit vs 64-bit environments. Java is portable because you
can carry bytecode over to any other platform it runs on.
5. Robust
The following features make Java strong and powerful:
 There is no use of explicit pointers
 Strong memory management
 Automatic garbage collection is done so you don’t need to
delete the unreferenced objects manually.
 Exception handling and type-checking mechanisms
6. Secure
 No explicit pointer
 Java Programs run inside a virtual machine sandbox
 Bytecode Verifier: It checks the code fragments for illegal
code that can violate access right to objects.
 Security Manager: It determines what resources a class can
access such as reading and writing to the local disk.
 The Security Manager decides what resources to allot to a
class. Such access can include reading and writing files.
 Java can help you develop virus-free systems.
7. Distributed
Java is distributed because it facilitates users to create distributed applications in Java. RMI
and EJB are used for creating distributed applications. This feature of Java makes us able to access
files by calling the methods from any machine on the internet.

8. 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.

9. 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.
Java Architecture – The Java Environment
1. JDK (Java Development Kit)
JDK is Kit which provides the environment to develop and
execute the Java program. It includes Development Tools to provide
an environment to develop your Java programs and JRE to execute
your java code. Along with the JRE, JDK contains other resources
like the interpreter/loader (java), the compiler (javac), an
archiver (jar), and a documentation generator (Javadoc). Together
these components help you to build Java programs.

2. JRE (Java Runtime Environment)


This is a collection of tools that together allow the
development of applications and provide a runtime environment. The
JVM is a part of JRE. This is like JVM, platform-dependent.
3. JVM (Java Virtual Machine)
The main purpose of Java Virtual Machine is to provide a
runtime environment in which bytecode executes. It is platform-
dependent, and has the following tasks:
•Load code
•Verify code
•Execute code
•Provide a runtime environment
The Architecture of JVM
1. Classloader
Classloader is a subsystem of JVM which is used to load class
files. Whenever we run the java program, it is loaded first by the
classloader. There are three built-in classloaders in Java.

a. Bootstrap ClassLoader: This is the first classloader which is


the super class of Extension classloader. It loads
the rt.jar file which contains all class files of Java Standard
Edition like java.lang package classes, java.net package
classes, java.util package classes, java.io package classes,
java.sql package classes etc.

b.Extension ClassLoader: This is the child classloader of Bootstrap


and parent classloader of System classloader. It loades the jar
files located inside JAVA_HOME/jre/lib/ext directory.
c. System/Application ClassLoader: This is the child classloader of
Extension classloader. It loads the classfiles from classpath. By default,
classpath is set to current directory. You can change the classpath using
"-cp" or "-classpath" switch. It is also known as Application classloader.

2. Class Area – This stores class structures like the runtime constant
pool, and the field and method data.

3. Heap – Heap is a section of memory that contains objects and also


contains reference variables. Instance variables are created in the heap.
This is the area in which data is allocated at runtime.

4. Stack – Stack is a section of the memory that contains methods, local


variables, and reference variables. Stack memory is always referenced in a
Last-In-First-Out manner. This holds local variables and intermediate
results. It also serves for method invocation.

5. PCR – The Program Counter Register holds the current instruction’s


address – the one which is being executed.
6. Native Method Stack – This consists of the native methods of
the application.

7. Execution Engine – This consists of an interpreter, a virtual


processor, and the JIT (Just-in-Time) compiler. The JIT compiles a
called method’s bytecode just in time; it is activated when we call
the method.

8. Java Native Interface – Abbreviated as JNI, this is a


framework that acts as an interface to communicate with another
application in a language like C++.
End

You might also like