1_Introduction to Java.pptx java programming

amitraj53904 24 views 26 slides Oct 18, 2024
Slide 1
Slide 1 of 26
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26

About This Presentation

Introduction to java


Slide Content

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Subject Name: Java Programming Day: 1 Topics Covered: Introduction to Java 1 Name of the School: School of Computer S cience and Engineering Course Code: E2UC304C Course Name:Java & Java Script Faculty Name : Programe Name: B.Tech (CSE,AI &ML )

Prerequisites, Objectives and Outcomes 2 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.

History of Java 3 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.

Object-Oriented Programming 4 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.

Salient Features of Java 5 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.

Salient Features of Java (Cond..) 6 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.

Java Language or Platform ? 7 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.

Where Java is used? 8 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

9 Getting Started with Java Programming

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

JDK VERSIONS 11 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)

JDK VERSIONS (Contd..) JDK VERSIONS (Contd..) 12 Java SE 8 (LTS) March 2014 January 2019 for Oracle (commercial) December 2030 for Oracle (non-commercial) 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 Java SE 11 (LTS) September 2018 September 2026 for Azul At least October 2024 for AdoptOpenJDK 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 Java SE 15 September 2020 March 2021 for OpenJDK March 2023 for Azul Java SE 16 March 2021 September 2021 for OpenJDK Java SE 17 (LTS) September 2021 September 2029 for Azul At least September 2027 for Microsoft Java SE 18 March 2022 September 2022 for OpenJDK

Installation of JDK 13 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

Life Cycle of Java Program 14 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.

15 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

Creating and Compiling Programs 16 To compile: open command prompt Go to the directory D:\Amit> D:\Amit> To compile the source code javac Filename D:\Amit> javac Welcome.java

17 Program Execution On command line java Filename D:Amit>java Welcome Program Execution

18 Execution of Java Program On command line java Filename Execution of Java Program

Write & Execute Java Program 19 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

The Bytecode 20 Compiled or interpreted? Both. Compiled into bytecode . Bytecode 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). The bytecode is the chips actual machine language.

The Java Execution Model 21 Java source code Java byte-code CPU 1 Native machine code CPU 2 Java chip Byte-code interpreter Byte-code compiler Java compiler Java virtual machine Java virtual machine Java machine Platform independent Platform dependent

Characteristics of Java 22 Java is simple Java is object-oriented Java is distributed Java is interpreted and has high performance Java is robust Java is secure Java is architecture-neutral Java is multithreaded Java is dynamic

23 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 bytecodes , 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.

24 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

References: 25 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/138-a2973dc6-c024-4d81-be6d-5c3344f232ce.pdf

26 Thank you
Tags