1.Introduction of Java
1.Introduction of Java
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?
• 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.
• 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
JDK
JRE Extra libraries to run the code
• 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 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.