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

Introduction to Java

The document outlines a Java Programming course offered by the School of Computer Science and Engineering, detailing prerequisites, objectives, and outcomes related to exception handling in Java. It covers the history of Java, its object-oriented programming features, salient characteristics, and various applications, as well as installation instructions for the Java Development Kit (JDK). Additionally, it explains the Java execution model, bytecode, and provides references for further learning.

Uploaded by

naimfaraz5
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Introduction to Java

The document outlines a Java Programming course offered by the School of Computer Science and Engineering, detailing prerequisites, objectives, and outcomes related to exception handling in Java. It covers the history of Java, its object-oriented programming features, salient characteristics, and various applications, as well as installation instructions for the Java Development Kit (JDK). Additionally, it explains the Java execution model, bytecode, and provides references for further learning.

Uploaded by

naimfaraz5
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Name of the School: School of Computer Science and

Engineering
Course Code: E2UC304C Course Name:Java & Java Script

DEPARTMENT OF COMPUTER SCIENCE


& ENGINEERING
Subject Name: Java Programming
Day: 1
Topics Covered: Introduction to Java

1
Faculty Name: Programe Name: B.Tech (CSE,AI &ML)
Prerequisites, Objectives and Outcomes
 Prerequisite of topic: Basic concepts related to java programming
 Objective: To make students aware about the different types of exceptions
along with numerous handling mechanisms available.
 Outcome : 1. Student will be able to know about types of exceptions in
Java.
2. Students will be able to understand various exception handling
mechanisms.
3. Students will be able to implement in practical applications.

2
History of Java
Java technology was created as a computer programming tool in a small,
secret effort called "the Green Project" at Sun Microsystems in 1991.
 They were trying to anticipate and plan for the "next wave" in computing. Their initial
conclusion was that at least one significant trend would be the convergence of digitally
controlled consumer devices and computers.

 A device-independent programming language code-named "Oak" was the result.


 To demonstrate how this new language could power the future of digital devices, the
Green Team developed an interactive, handheld home-entertainment device controller
targeted at the digital cable television industry. But the idea was too far ahead of its time,
and the digital cable television industry wasn't ready for the leap forward that Java
technology offered them.
 In 1995, the team was able to announce that the Netscape Navigator Internet browser
would incorporate Java technology.
3
Object-Oriented Programming
 One of the most important characteristics of procedural programming is that it relies on procedures that
operate on data – these (Procedure and data) are two separate concepts.
 In object-oriented programming, these two concepts are bundled into objects.
 Object-oriented programming, or OOP, is an approach to problem-solving where all computations are
carried out using objects. An object is a component of a program that knows how to perform certain actions
and how to interact with other elements of the program.

 Objects are the basic units of object-oriented programming. A simple example of an object would be a
person. Logically, you would expect a person to have a name. This would be considered a property of the
person.
 You would also expect a person to be able to do something, such as walking. This would be considered a
method of the person.

4
Salient Features of Java
 Your Java programming language is object oriented, yet it's still dead simple.
 Your development cycle is much faster because Java technology is interpreted. The compile-
link-load-test-crash-debug cycle is obsolete--now you just compile and run.
 Your applications are portable across multiple platforms. Write your applications once, and you
never need to port them--they will run without modification on multiple operating systems and
hardware architectures.
 Your applications are robust because the Java runtime environment manages memory for you.

5
Salient Features of Java (Cond..)
Your interactive graphical applications have high performance because
multiple concurrent threads of activity in your application are supported by
the multithreading built into the Java programming language and runtime
platform.

Your applications are adaptable to changing environments because you can


dynamically download code modules from anywhere on the network.

Your end users can trust that your applications are secure, even though
they're downloading code from all over the Internet; the Java runtime
environment has built-in protection against viruses and tampering.
6
Java Language or Platform ?
Java is one of the world's most widely used computer language. Java is a simple,
general-purpose, object-oriented, interpreted, robust, secure, architecture-neutral,
portable, high-performance, multithreaded computer language.
It is intended to let application developers "write once, run anywhere"
(WORA), meaning that code that runs on one platform does not need to be
recompiled to run on another.
Java technology is both a programming language and a platform.
Java is a high level, robust, secured and object-oriented programming language.
And any hardware or software environment in which a program runs, is known
as a platform.
Since Java has its own runtime environment (JRE) and API, it is called platform.

7
Where Java is used?
There are many devices where java is currently used.
Some of them are as follows:
Desktop Applications
Web Applications
Mobile
Embedded System
Robotics
Games etc

8
Getting Started with Java
Programming

9
Requirement of Software in Java
Programming
 Download Free software Java Development Kit (JDK 1.5 or above)
 One Editor to write Source code
 Notepad
 Edit plus
 Java supporting IDE

10
JDK VERSIONS
Major release versions of Java, along with their release dates:
JDK 1.0 (January 21, 1996)
JDK 1.1 (February 19, 1997)
J2SE 1.2 (December 8, 1998)
J2SE 1.3 (May 8, 2000)
J2SE 1.4 (February 6, 2002)
J2SE 5.0 (September 30, 2004)
Java SE 6 (December 11, 2006)
Java SE 7 (July 28, 2011)
Java SE 8 (March 18, 2014)

11
JDK VERSIONS (Contd..)
JDK VERSIONS (Contd..)

January 2019 for Oracle (commercial)


December 2030 for Oracle (non-commercial)
Java SE 8 (LTS) March 2014 December 2030 for Azul
At least May 2026 for AdoptOpenJDK
At least May 2026 for Amazon Corretto
Java SE 9 September 2017 March 2018 for OpenJDK
Java SE 10 March 2018 September 2018 for OpenJDK
September 2026 for Azul
At least October 2024 for AdoptOpenJDK
Java SE 11 (LTS) September 2018
At least September 2027 for Amazon Corretto
At least October 2024 for Microsoft
Java SE 12 March 2019 September 2019 for OpenJDK
Java SE 13 September 2019 March 2020 for OpenJDK
Java SE 14 March 2020 September 2020 for OpenJDK
March 2021 for OpenJDK
Java SE 15 September 2020
March 2023 for Azul
Java SE 16 March 2021 September 2021 for OpenJDK
September 2029 for Azul
Java SE 17 (LTS) September 2021
12 At least September 2027 for Microsoft
Java SE 18 March 2022 September 2022 for OpenJDK
Installation of JDK
 Steps to Install & Run Java Program
 1. Download JDK
 2. Set path using environment variable
 Environment Variable:

JAVA_HOME :- path upto JDK


C:\Program Files (x86)\Java\jdk1.8.0;
path :- path upto bin directory
C:\Program Files (x86)\Java\jdk1.8.0\bin;

 3. Open an editor -> write java code -> save file with .java extension
 4. Open command prompt -> To compile: - C>javac Abc.java
To run > C> java Abc

13
Life Cycle of Java Program
Life Cycle of Java Program
 In the Java programming language, all source code is first written in plain text files ending
with the .java extension.
 Those source files are then compiled into .class files by the javac compiler.
 A .class file does not contain code that is native to your processor; it instead contains
bytecodes — the machine language of the Java Virtual Machine1 (Java VM).
 The java launcher tool then runs your application with an instance of the Java Virtual
Machine.

14
Getting Started with Java Programming
//This application program prints Welcome to Java!
public class Welcome
{
public static void main(String args[ ])
{
System.out.println("Welcome to Java!");
}
}
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
 Create one directory say AMIT in D drive
 Save this file with name “Welcome.java” in Amit directory

15
Creating and Compiling Programs

Create/Modify Source Code

To compile: open command


prompt Go to the directory Source Code

D:\Amit>
Compile Source Code
• D:\Amit> i.e. javac Welcome.java

If com pilation errors


• To compile the source code
Bytecode
• javac Filename
• D:\Amit> javac Run Byteode
i.e. java Welcome
Welcome.java

Result

16 If runtime errors or incorrect result


ProgramProgram Execution
Execution
 On command line
 java Filename
 D:Amit>java
Welcome
Bytecode

Java Java Java


Interpreter Interpreter Interpreter
...
on Windows on Linux on Sun Solaris

17
Execution of Java Program
Execution of Java Program

 On command line
 java Filename

Bytecode

Java Java Java


Interpreter Interpreter Interpreter
...
on Windows on Linux on Sun Solaris

18
Write & Execute Java Program
Open Notepad
Write java program
Compile your program
D:Amit>javac Welcome.java

Execute your class file


D:Amit>java Welcome

output:... Welcome to Java

19
The Byte code
Compiled or interpreted?
Both.
Compiled into byte code.
 Byte code is in then interpreted by the java virtual machine.
 Each platform has it’s own java virtual machine on it.
 There are three ways of handing the byte code.
 There could be a byte-code interpreter.
 There could be a byte-code compiler for the machine that is it actually
run on.
 There could be a java chip (which is underdevelopment).
o The byte code is the chips actual machine language.

20
The Java Execution Model
Java source code

Platform
Java compiler
independent

Java byte-code

Java chip
Byte-code Byte-code
interpreter compiler
Java machine

CPU1 Native machine code


Platform
Java virtual machine dependent
CPU2
21
Java virtual machine
Characteristics of Java
1. Java is simple
2. Java is object-oriented
3. Java is distributed
4. Java is interpreted and has high performance
5. Java is robust
6. Java is secure
7. Java is architecture-neutral
8. Java is multithreaded
9. Java is dynamic

22
 Avoid platform dependencies: You can keep your program portable by
avoiding the use of libraries written in other languages.

 Write once, run anywhere: Because applications written in the Java


programming language are compiled into machine-independent byte codes,
they run consistently on any Java platform.

 Distribute software more easily: With Java Web Start software, users will
be able to launch your applications with a single click of the mouse.
 An automatic version check at startup ensures that users are always up to
date with the latest version of your software. If an update is available, the
Java Web Start software will automatically update their installation.

23
Get started quickly: Although the Java programming language is a
powerful object-oriented language, it's easy to learn, especially for
programmers already familiar with C or C++.
Write less code: Comparisons of program metrics (class counts, method
counts, and so on) suggest that a program written in the Java programming
language can be four times smaller than the same program written in C++.
Write better code: The Java programming language encourages good
coding practices, and automatic garbage collection helps you avoid memory
leaks. Its object orientation, its JavaBeans™ component architecture, and its
wide-ranging, easily extendible API let you reuse existing, tested code and
introduce fewer bugs.
Develop programs more quickly: The Java programming language is
simpler than C++, and as such, your development time could be up to twice
as fast when writing in it. Your programs will also require fewer lines of code

24
References:
 https://www.geeksforgeeks.org/
 https://www.javatpoint.com/exception-handling-in-java
 https://www.tutorialspoint.com/java/java_exceptions.htm
 The complete reference, eleventh edition, available at:
https://gfgc.kar.nic.in/sirmv-science/GenericDocHandler/1
38-a2973dc6-c024-4d81-be6d-5c3344f232ce.pdf

25
Thank you

26

You might also like