0% found this document useful (0 votes)
4 views

1.Introduction of Java

The document provides an introduction to Java, covering its history, features, and comparisons with C++. It highlights Java as an object-oriented programming language that is platform-independent and discusses its benefits, applications, and the concepts of JVM and JRE. Additionally, it explains the basics of Java programming, including a simple program example and the differences between PATH and CLASSPATH.

Uploaded by

Neha Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

1.Introduction of Java

The document provides an introduction to Java, covering its history, features, and comparisons with C++. It highlights Java as an object-oriented programming language that is platform-independent and discusses its benefits, applications, and the concepts of JVM and JRE. Additionally, it explains the basics of Java programming, including a simple program example and the differences between PATH and CLASSPATH.

Uploaded by

Neha Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Object Oriented Programming with Ja

Introduction to
Java

Rita Nagar
Assistant Professor, CSE Department MPGI
Outlines
• Introduction to Java
• History of Java
• Comparison of Java and C++
• Java as an object-oriented language
• Benefits and applications of Java
• JVM and JRE
• program, compile and execute Java code
• concept of path and class path
What is Java?

Java is a programming language and a platform.

Platform : Any hardware and software in which a


program runs is known as platform.
As Java provide its own runtime environment
(JRE) and APL , it is called platform.
• Java is a class-based, object-oriented programming
language and is designed to have as few implementation
dependencies as possible. A general-purpose
programming language made for developers to write
once run anywhere that is compiled Java code can run on
all platforms that support Java. Java applications are
compiled to byte code that can run on any Java Virtual
Machine. The syntax of Java is similar to c/c++.
History of Java

• Java is a popular programming language that was first


released in 1995 by Sun Microsystems and later acquired
by Oracle Corporation
• Its originally called Oak , but was later renamed Java

• Java is an island in 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
. a cup of coffee nearby his office.
• James Gosling, Mike Sheridan, and Patrick Naughton
initiated the Java language project in June 1991. The small
team of sun engineers called Green Team.
• On 13 November 2006, Sun launched a considerable
amount of Java in the GNU General Public License as
free and open-source software (GPL) (GPL).

• On 8 May 2007, Sun completed the process by


releasing a fully accessible, all-free, and open-source
Java core code, except for a small portion of the code
that Sun did not copyright.
Java Versions History
Sr.No. Version Date Description
1 JDK Beta 1995 Initial Draft version

2 JDK 1.0 23 Jan 1996 A stable variant JDK 1.0.2 was


termed as JDK 1
Major features like JavaBeans,
3 JDK 1.1 19 Feb 1997 RMI, JDBC, inner classes were
added in this release.
Feature added - String
Templates (Preview),
JAVA SE 21 19 Sep 2023 Sequenced Collections,
4 Generational ZGC, Record
Patterns, Pattern Matching for
switch etc.
Comparison of Java and C++
COMPARISON C++ JAVA
PARAMETER
C++ was developed by Bjarne Java was developed by James
Developed / Founded by Stroustrup at Bell Labs in 1979.
It was developed as an Gosling at Sun Microsystems.
extension of the C language. Now, it is owned by Oracle.
It has support for both Java has support only for object-
Programming model procedural programming and
object-oriented programming. oriented programming models.
C++ is platform dependent. It is Java is platform-independent. It is
Platform dependence based on the concept of Write based on the concept of Write
Once Compile Anywhere. Once Run Anywhere.
C++ supports features like Java does not support features
Features supported operator overloading, Goto like operator overloading, Goto
statements, structures, statements, structures, pointers,
pointers, unions, etc. unions, etc.
C ++ is only compiled and Java can be both compiled and
Compilation and Interpretation cannot be interpreted. interpreted.
Java, on the other hand, has
more diverse libraries with a lot
C++ has very limited libraries of support for code reusability.
Library and Code reusability with low-level functionalities. In Java, only calls through the
support C++ allows direct calls to native Java Native Interface and
system libraries. recently Java Native Access are
allowed.
In C++, memory management is In Java, memory management
Memory Management manual. is System controlled.
C++ is pretty consistent
Type semantics between primitive and object In Java, semantics differs for
types. primitive and object types.
In C++, both global and
Global Scope namespace scopes are Java has no support for global
supported. scope.
In Java, the model is
Access control and object In C++, a flexible model with cumbersome and encourages
protection constant protection is available. weak encapsulation.
Java as an object-oriented language

• OOPs refers to languages that use objects in programming

• The main aim of OOP is to bind together the data and the
functions that operate on them so that no other part of the
code can access this data except that function.

• The main aim of object-oriented programming is to implement


real-world entities, for example, object, classes, abstraction,
inheritance, polymorphism, etc.
Benefits and applications of Java
• Java is easy to learn.
• Java was designed to be easy to use and is therefore easy to write,
compile, debug, and learn than other programming languages.
• Object-Oriented Programming
• This allows you to create modular programs and reusable code.
• It promotes best coding practices for concepts such as
encapsulation, inheritance, and polymorphism, which, in turn,
leads to more maintainable and scalable code.
• Multi-thread abilities
• This program has multi-thread abilities, which means you can
operate more than one thread concurrently. A thread is the
smallest unit in programming. Multi-threads help computers make
the most of their central processing unit (CPU) to improve the
performance and competence of the computer's applications.
• Automates memory process
• The program does the allocation and distribution of the
memory. Memory allocation and distribution mean it does not
require you to move the memory around unless you desire it in
a different folder or place. Additionally, it does not require you
to delete unused and unlinked information because it does it
automatically.

• Platform Independence
• As noted, Java’s WORA principle is a big highlight for the
language, as Java programs can be compiled on a single
platform and executed across any platform featuring the JVM,
which constitutes most modern systems. This makes Java very
compatible and affords it a high degree of portability.
Applications of Java

• Desktop GUI Applications


• Mobile Applications
• Artificial intelligence
• Web applications
• Big Data technology
• Gaming applications
• Business applications
• Embedded systems
• Cloud applications
• Scientific applications
• Mobile Applications
• Java is a cross-platform framework that is used to build applications
that run across smartphones and other small-screen devices.
• Artificial Intelligence
• Java is one of the best languages for AI projects. Its infrastructure is well
embedded with intelligent software to enhance AI programming. It has
amazing features like better interaction with users, ease of debugging,
easy-to-code features, standard widget tools, and a lot more.
• Web Applications
• It allows us to create dynamic web applications that interact with
interfaces. The presence of JSP, web servers, spring, and Hibernate
provides feasibility in the web development process.
• Big Data Technology
• It is a software utility designed to analyze and extract information from
complex data structures. It is widely used in other technologies like
deep learning, Machine learning, and Artificial learning.
JVM and JRE
• JVM (Java Virtual Machine) is an abstract machine. It is called a virtual
machine because it doesn't physically exist. It is a specification that
provides a runtime environment in which Java bytecode can be executed.
It can also run those programs which are written in other languages and
compiled to Java bytecode.

JDK
JRE Extra libraries to run the code

JVM It is the place where we run our code


To make java platform independent
A simple program, its compilation and
execution;
• public class t
• {
• public static void main(String[] args)
• { Save this file as
t.java
• System.out.println(“Hello world");
• }
• }
public static void main(String[] args)
• public: This keyword means that the method is accessible anywhere,
including from outside the class it’s declared in.

• static: By using ‘static’, we’re saying that the main method can be run
without needing an instance of the class.

• void: This keyword indicates that the main method doesn’t return any value.

• main: ‘main’ is the name of this method. The JVM looks for a method with
this name when it starts running a program.

• String[] args: This is an array of ‘String’ objects. It’s used to receive any
command-line arguments that were passed when the program was started.
Concept of path and class path.

• PATH is an environment variable. It is used by the operating


system to find the executable files (.exe). You are required to
include the directory which contains .exe files.

• CLASSPATH is that Path is set for java tools in java programs


like java and javac, which are used to compile your code.
• Classpath is system environment variable used by the Java
compiler and JVM. Java compiler and JVM is used classpath
to determine the location of required class files.
Difference between PATH and CLASSPATH

PATH CLASSPATH
CLASSPATH is also an environment
PATH is an environment variable. variable.
It is used by the operating system to It is used by Application ClassLoader
find the executable files (.exe). to locate the .class file.
You are required to include all the
You are required to include the directories which contain .class and
directory which contains .exe files. JAR files.
The CLASSPATH environment
variable can be overridden by using
PATH environment variable once the command line option -cp or -
set, cannot be overridden.
CLASSPATH to both javac and java
command.

You might also like