Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.

Similar presentations


Presentation on theme: "Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi."— Presentation transcript:

1 Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi

2 Office# 78-A Office hours : S.M.W 10-11 S…W 12:30-2 Email : omaima_almatrafi@yahoo.comomaima_almatrafi@yahoo.com 2

3 Java - General Java is: ▫High level language similar to C++ in syntax ▫Platform independent programming language 3

4 Compile-time Environment Java Bytecodes move locally or through network Java Source (.java) Java Compiler Java Bytecode (.class ) Java Interpreter Just in Time Compiler Runtime System Class Loader Bytecode Verifier Java Class Libraries Operating System Hardware Java Virtual machine How it works…! 4

5 Java is independent only for one reason: ▫Only depends on the Java Virtual Machine (JVM). ▫The Java compiler produces a special format called byte code, which is interpreted by the resident JVM (regardless of computer architecture), ▫JIT (just in time) compilers attempt to increase speed. Write Once, Run everywhere 5

6 Java Features Portable - Write Once, Run Anywhere Automatic memory management Designed for network programming Multi-threaded (multiple simultaneous tasks) Dynamic & extensible (loads of libraries) ▫Classes stored in separate files ▫Loaded only when needed Security has been well thought through 6

7 Java lets you write special programs called applets that can be downloaded from the Internet and played safely within a web browser. Java restricts what an applet can do. ▫A Java applet cannot write to your hard disk without your permission. ▫It cannot write to arbitrary addresses in memory and thereby introduce a virus into your computer. ▫It should not crash your system. 7

8 Software required: Java Development Kit (JDK) version 5 ▫ Download: http://java.sun.com/javase/http://java.sun.com/javase/ JCreator LE version ▫http://www.jcreator.org/download.htmhttp://www.jcreator.org/download.htm 8

9 Java Development Kit (JDK) (JDK) is a Sun Microsystems product aimed at Java developers. Some of JDK contents: ▫java – The loader for Java applications. This tool is an interpreter. ▫javac – The compiler, which converts source code into Java bytecode. ▫jar – The archiver, which packages related class libraries into a single JAR file. ▫jdb – The debugger ▫appletviewer – This tool can be used to run and debug Java applets without a web browser. 9

10 Some Object-Oriented Terminology A Class : A class defines the abstract characteristics of a thing and its behavior. An Object : An exemplar of a class. it consists of state and related behavior. An object stores its state in fields and exposes its behavior through methods. Inheritance: programming allows classes to inherit commonly used state and behavior from other classes. use the extends keyword, followed by the name of the class to inherit from: class subClass extends superClass 10

11 Interface: just like classes except that they use the word interface instead of class and is restricted to containing method declarations without bodies. Interface interface_name { } And to use the interface in the class definition: Public class class_name implements interface_name { } A package: is a namespace that organizes a set of related classes and interfaces. The Java platform provides an enormous class library (a set of packages). This library is known as the "Application Programming Interface", or "API“. 11 Some Object-Oriented Terminology

12 Language Basics Variables ▫Instance Variables (Non-Static Fields) ▫Class Variables (Static Fields) ▫Local Variables (method’s variables) ▫Parameters Primitive Data Types: byte, short, int, long, float, double, boolean, char. Arrays 12

13 Reading from a file For writing a java program to read file line by line: ▫Use import java.io.*; ▫Define FileInputStream object to obtain input bytes from a file in a file system (to open the file). ▫Define DataInputStream object to let an application read primitive Java data types from an underlying input stream in a machine-independent way. ▫Define InputStreamReader object which is used as a bridge from byte streams to character streams. 13

14 Reading from a file Cont. 14 ▫Define BufferedReader object to Read text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines. ▫Read File Line By Line using readLine() method of BufferedReader object. ▫Close the input stream.

15 Good References http://java.sun.com/docs/books/tutorial/java/i ndex.htmlhttp://java.sun.com/docs/books/tutorial/java/i ndex.html GOOD LUCK 15

16 Need to do… 16 Practice to write to a file… You will need that later in your HWs. For writing to a file, you will need to use FileOutputStream object.


Download ppt "Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi."

Similar presentations


Ads by Google