1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.
-
date post
19-Dec-2015 -
Category
Documents
-
view
224 -
download
3
Transcript of 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.
![Page 1: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/1.jpg)
1
Introduction to Introduction to Java and AppletJava and AppletLecture 3Lecture 3 from Chapters 1 from Chapters 1
and 2 of the complete and 2 of the complete referencereference
![Page 2: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/2.jpg)
2
Java’s LineageJava’s Lineage• Java is related to C+.• Java is a direct descendent of C.• Java’s object-oriented features were
influenced by C++• Java was developed by James Gosling
etc. at Sun Mircosystems in 1991.• It was called “oak” and was renamed
as Java.
![Page 3: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/3.jpg)
3
Java and the InternetJava and the Internet• Java is a portable, platform-
independent language that could be used to produce code that would run on different platform.
• Java expands the universe of objects that can move freely in Cyberspace.
• It is ideal for client [windows]-server [linux] platform.
![Page 4: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/4.jpg)
4
Java AppletsJava Applets• Java supports two types of programs:
applications and applets• An application: It is a program that
runs on our PC under windows XP.• An applet: It is a tiny Java program,
dynamically downloaded across the network, like music, video clip.
![Page 5: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/5.jpg)
5
SecuritySecurity• Without Java, Once you are downloading
an executable program, there is a risk of viral infection.
• If it is written in Java using Java-compatible browser, it is pretty safe.
• Java also provides a “firewall” between a networked application and our PC to safe-guard information such as credit card number, bank account balance.
![Page 6: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/6.jpg)
6
Java’s Merit- Java’s Merit- Interpreter and BytecodeInterpreter and Bytecode
• Java that resolves security and portability problems is because the output of a Java Compiler is not executable code (not .exe or .com).
• It is bytecode. • Bytecode is an optimised codes to be
executed by the Java Run Time system.• Java run-time system is an interpreter.
![Page 7: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/7.jpg)
7
Java Overview – Java Overview – some key elementssome key elements
• Simple: simple and easy to learn • Object-oriented: Clean, usable approach to
objects• Robust: reliable under different operating
environments across the networks (The Internet)
• Mutlithreaded: supports a few light weight processes
• Interpreted: Although it is an interpreted language, the performance is good.
![Page 8: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/8.jpg)
8
Download Java Compiler (1)Download Java Compiler (1)
![Page 9: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/9.jpg)
9
Download Java Compiler (2)Download Java Compiler (2)
![Page 10: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/10.jpg)
10
Download Java SDK (3)Download Java SDK (3)
![Page 11: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/11.jpg)
11
Installing Standard- Installing Standard- Java 2 SDKJava 2 SDK
![Page 12: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/12.jpg)
12
Installation - Installation - check whether you check whether you have installed java and javac have installed java and javac
![Page 13: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/13.jpg)
13
Set the path to include the directory Set the path to include the directory
Test it by typing javac in other directory
![Page 14: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/14.jpg)
14
JDK componentsJDK components• appletviewer.exe applet viewer• java.exe intepreter• javac.exe compiler• javadoc.exe document generator
• javap.exe decompiler• jdb.exe debugger
![Page 15: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/15.jpg)
15
A simple ProA simple Program – javac & javagram – javac & java
![Page 16: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/16.jpg)
16
Explanation to the first programExplanation to the first program
![Page 17: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/17.jpg)
17
Explanation to the first programExplanation to the first program• Class: First is the name of class. It will
generate a First.class after compilation (javac)
• Public: is an access specifier that allows the programmer to control
• Main(): must be declared as public so that it can be accessed.
• String args[]: argv[0] is the first argument• System.out.println: Display the contents
followed by a line feed
![Page 18: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/18.jpg)
18
Second ProgramSecond Program
![Page 19: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/19.jpg)
19
Second Program - Second Program - ExplanationExplanation
• int num; declares an integer valuable called num
• Num = 10; assign a value of 10• System.out.println("The value of num
is " + num); The “+” causes the value of num to be displayed
• .println() ; displays the string passed • .print(); display the string without
line feed
![Page 20: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/20.jpg)
20
Applet (1)Applet (1)
![Page 21: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/21.jpg)
21
Applet (2) – the resultApplet (2) – the result
![Page 22: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/22.jpg)
22
Explanation to AppletExplanation to Applet• Prepare a java
program called third
• In the HTML, specify the class of the program (third)
• Use appletviewer or IE explorer to see the result
![Page 23: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/23.jpg)
23
Javadoc - Javadoc - Document GeneratorDocument Generator
![Page 24: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/24.jpg)
24
Javadoc – some exampleJavadoc – some example
![Page 25: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/25.jpg)
25
Javadoc.exeJavadoc.exe
• Javadoc is a tool shipped with JDK that generates HTML documentation from the comments in the class source files.
• With the aid of Javadoc we can simplify documentation of our code and make it a regular habit.
![Page 26: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/26.jpg)
26
Javap – decompilerJavap – decompiler
![Page 27: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/27.jpg)
27
Javap - explanationJavap - explanation• The javap
command disassembles a class file.
• Its output depends on the options used. If no options are used, javap prints out the package.
![Page 28: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/28.jpg)
28
Jdb – DebuggerJdb – Debugger
![Page 29: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/29.jpg)
29
Jdb - explanationJdb - explanation• The Java Debugger, jdb, is a simple
command-line debugger for Java classes.
• It provides inspection and debugging of a local or remote Java Virtual Machine.
• Jdb class format
![Page 30: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/30.jpg)
30
Jdb – helpJdb – help
![Page 31: 1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d3e5503460f94a16867/html5/thumbnails/31.jpg)
31
SummarySummary• Java is related to C+.• Java is a direct descendent of C.• Java’s object-oriented features were in
fluenced by C++• It is ideal for client [windows]-server [Lin
ux] platform.