Click here to load reader

Introduction To java 1 CT1513 © A.AlOsaimi. What is Java 2 Java is a programming language and computing platform first released by Sun Microsystems in

Embed Size (px)

Citation preview

CT1513

Introduction To java1CT1513

A.AlOsaimiWhat is Java2Java is a programming language and computing platform first released by Sun Microsystems in 1995.

A.AlOsaimiWhy?3Java is the first programming language to deliberately embrace the concept of writing programs that can be executed on the Web.

The Java language is accompanied by a library of extra software that we can use when developing programs.The library provides the ability to create graphics, communicate over networks, and interact with databases.The set of supporting libraries is huge.

A.AlOsaimiJava vs. C++4Both Java and C++ are most popular object-oriented programming languages

C++ was created at AT&T Bell Labs in 1979

Java was born in Sun Microsystems in 1990

The language derives much of itssyntaxfromC andC++but has a simplerobject modeland fewerlow-levelfacilities.

A.AlOsaimiJava applications and applets5Applications standalone Java programs

Applets Java programs that run inside web browsers A.AlOsaimi5Compiling Java Programs6The Java compiler produces bytecode (a .class file) not machine code from the source code (the .java file).Bytecode is converted into machine code using a Java Interpreter

Source CodeBytecode A.AlOsaimi6Platform Independent Java Programs Compiling7You can run bytecode on any computer that has a Java Interpreter installed

Hello.javaHello.class A.AlOsaimi7Multipurpose Java Compiling8

A.AlOsaimi8Running The Program9ClassLoaderBytecodeInterpreterBytecode VerifierHardwareOperating SystemJVMThe Bytecode(the .class file)Running A.AlOsaimi9The Java Virtual Machine Components10The Class Loaderstores bytecodes in memoryBytecode Verifierensures bytecodes do not violate security requirementsBytecode Interpretertranslates bytecodes into machine language A.AlOsaimi10The Java Virtual Machine11The class Loader, the Bytecode Verifier and Interpreter constitute the Java Virtual Machine (JVM).

JVM is platform specific.The interpreter translates the bytecodes into specific machine commands.

A.AlOsaimi11PrimaryMemory......DiskDiskDiskEditorCompilerClass LoaderProgram is created in an editor and stored on disk in a file ending with .java.Compiler creates bytecodes and stores them on disk in a file ending with .class.Class loader reads .class files containing bytecodes from disk and puts those bytecodes in memory.Phase 1Phase 2Phase 3PrimaryMemory......Bytecode VerifierBytecode verifier confirms that all bytecodes are valid and do not violate Javas security restrictions.Phase 4PrimaryMemory......InterpreterInterpreter reads bytecodes and translates them into a language that the computer can understand, possibly storing data values as the program executes.Phase 5Java Development Environment12 A.AlOsaimi12Some Characteristics of Java13Object-OrientedCombines data and behavior into one unit objectsProvides Data abstraction and encapsulationDecompose program into objects.Programs are collections of interacting and cooperating objects.Platform-independentPortableWrite-once, run-anywhere SecureThe bytecode verifier of the JVM :checks untrusted bytecode controls the permissions for high level actions. A.AlOsaimiPortable- the feature Write-once-run-anywhere, also have the standard data size irrespective of operating system or processor. Dynamic- the user can get the required files from a local drive or from a computer far away from the user, just by connecting with the Internet. Secure- The security manager, determines the accessibility options of a class like reading and writing a file to the local disk. Java uses the public key encryption system to allow the java applications to transmit over the Internet in the secure encrypted form13Example of Java Programming Code14

A.AlOsaimi