Download presentation
Presentation is loading. Please wait.
1
1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference
2
2 Java ’ 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.
3
3 Java 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.
4
4 Java 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.
5
5 Security 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.
6
6 Java ’ s Merit- Interpreter 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.
7
7 Java Overview – some 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.
8
8 Download Java Compiler (1)
9
9 Download Java Compiler (2)
10
10 Download Java SDK (3)
11
11 Installing Standard- Java 2 SDK
12
12 Installation - check whether you have installed java and javac
13
13 Set the path to include the directory Test it by typing javac in other directory
14
14 JDK components appletviewer.exeapplet viewer java.exeintepreter javac.execompiler javadoc.exe document generator javap.exedecompiler jdb.exedebugger
15
15 A simple Program – javac & java
16
16 Explanation to the first program
17
17 Explanation 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
18
18 Second Program
19
19 Second Program - Explanation 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
20
20 Applet (1)
21
21 Applet (2) – the result
22
22 Explanation 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
23
23 Javadoc - Document Generator
24
24 Javadoc – some example
25
25 Javadoc.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.
26
26 Javap – decompiler
27
27 Javap - 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.
28
28 Jdb – Debugger
29
29 Jdb - 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
30
30 Jdb – help
31
31 Summary Java is related to C+. Java is a direct descendent of C. Java ’ s object-oriented features were influenced by C++ It is ideal for client [windows]-server [Linux] platform.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.