Presentation is loading. Please wait.

Presentation is loading. Please wait.

1. 2 is high level programming language like C++, Visual Basic, developed by James Gosling and Patrick Naughton at Sun Microsystems in 1991.

Similar presentations


Presentation on theme: "1. 2 is high level programming language like C++, Visual Basic, developed by James Gosling and Patrick Naughton at Sun Microsystems in 1991."— Presentation transcript:

1 1

2 2 is high level programming language like C++, Visual Basic, developed by James Gosling and Patrick Naughton at Sun Microsystems in 1991.

3 3 You can use Java to write computer applications of numbers, process words, play games, store data or do any of the thousands of other things computer software can do. Java is most similar to C and C++. The special programs called Applets that can be downloaded from the Internet and played safely within a web browser.

4 4

5 5 You may wonder how Sun’s engineers were able to develop such a powerful software development environment and surpass all known programming languages. The origins of Java trace back to 1991, when Sun was investigating consumer electronics products.

6 6 James Gosling, the father of Java, was intent on building a low-cost, hardware-independent software platform using C++. For a number of technical reasons, C++ was dropped, and a new language, called Oak, was developed, based on C++, but eliminating its shortcomings.

7 7 Oak was used to develop a small electronics device called “Star 7”. By 1994 the Web emerged, Oak was renamed Java, Java was used as the basis for a Web browser, called WebRunner. WebRunner was successfully demonstrated, and the Java/HotJava project took off.

8 8 HotJava, Java, and the Java documentation and source code were made available over the Web, as an alpha version, in early 1995. Initially Java was hosted on SPARC Solaris, and then on Windows NT. In the summer of 1995, Java was ported to Windows 95 and Linux.

9 9 In the fall of 1995 the Java Beta 1 version was released through Sun's Web site, and Java support was introduced in the Netscape 2.0 browser. In December 1995 the Java Beta 2 version was released, and JavaScript was announced by Sun and Netscape.

10 10 Java's success became inevitable when, in early December, both Microsoft and IBM announced their intention to license Java technology. On January 23, 1996, Java 1.0 was officially released and made available for download over the Internet.

11 11

12 12 1- Java is a Platform 2- Java is Simple 3- Java is Object-Oriented 4- Java is Platform Independent 5- Java is Safe

13 13 6- Java is High Performance 7- Java is Multi-Threaded 8- Java is Dynamically linked 9- Java is Garbage Collected 10- Network Facilities

14 14 JAVA IS A PLATFORM Java is a platform for application development. A platform is a loosely defined computer industry that typically means some combination of hardware and system software that will mostly run all the same software.

15 15 Computer programs are very closely tied to the specific hardware and operating system they run. A Windows program will not run on a computer that only runs DOS. A Mac application can't run on a Unix workstation and so on.

16 16 Java solves the problem of platform- independence by using BYTECODE. The Java compiler does not produce native executable code for a particular machine like a C compiler would. Instead it produces a special format called BYTECODE.

17 17 The interpreter reads the BYTECODE and translates it into the native language of the host machine. Since the BYTECODE is completely platform independent, compiler and most of the class libraries are written in Java Platform.

18 18 All these pieces, the javac (Compiler), the java (Interpreter), the Java Programming Language, and more are collectively referred to as Java Platform.

19 19 JAVA IS SIMPLE Java was designed to make it much easier to write bug free code. The most important part of helping programmers write bug-free code is keeping the language simple.

20 20 About half of the bugs in C and C++ programs are related to Memory Allocation and Deallocation. Therefore the second important addition Java makes to providing bug-free code is Automatic memory allocation and deallocation.

21 21 JAVA IS OBJECT-ORIENTED In object-oriented programs data is represented by objects. Objects have two sections, fields (instance variables) and methods. Fields tell you what an object is. Methods tell you what an object does.

22 22 Object oriented programming have a number of advantages including Simpler, easier to read programs, More efficient reuse of code, Faster time to market and More powerful, error-free code. Object-oriented language C++ is a complex, difficult language.

23 23 JAVA IS PLATFORM INDEPENDENT Java is compiled to an intermediate form called BYTECODE. A Java program never really executes natively on the host machine. Rather a special native program called the Java interpreter reads the BYTECODE

24 24 The BYTECODES are precisely defined and remain the same on all platforms. In Java everything is guaranteed. However the Virtual Machine (VM) itself and some parts of the class library must be written in native code.

25 25 JAVA IS SAFE Most notably there are no Pointers in Java. Java programs cannot access optional addresses in memory. All memory access is handled behind the scenes by the trusted runtime environment. Furthermore Java performs strong type checking.

26 26 JAVA IS DYNAMICALLY LINKED Java source code is divided into.java files, roughly one per each class in your program. The compiler compiles these into.class files containing BYTECODE. Each.java file generally produces exactly one.class file.

27 27 The compiler searches the current directory and directories specified in the CLASSPATH environment variable to find other classes explicitly referenced by name in each source code file. Furthermore, Java.class files tend to be quite small, a few kilobytes at most.

28 28 JAVA IS GARBAGE COLLECTED You do not need to explicitly allocate or deallocate memory in Java. Memory is allocated and reclaimed by the Garbage Collector when it is no longer needed.

29 29 There are constructors and these do allocate memory but this is transparent to the programmer. Most Java virtual machines (JVM) use an inefficient, mark and sweep garbage collector.

30 30 NETWORK FACILITIES Java has an extensive library of routines for handling easily with TCP/IP protocols like HTTP and FTP. This makes creating network connections much easier than in C or C++. Java applications can open and access objects across the net via URLs same as local file access system.

31 31 JAVA vs C++ 1.No Preprocessor #define in Java. 2.No Pointers in Java. 3.No Structures and Unions in Java. 4.No Multiple Inheritance in Java.

32 32 5. No need to make null terminated characters array for Strings Java have built in support for Strings. 6. No goto statement in Java. 7. No operator overloading in Java. 8. No Global Functions in Java. 9. No Global Variables in Java.

33 33

34 34 JAVA’s main strength is its unique architecture. Java provides facilities of networking as well as at the same time works on a wide range of platforms.

35 35 Most compilers produce machine code (understood by the central processor). Some produce intermediate code (not understood by the central processor).

36 36 But, Java compiler generates system architecture independent BYTECODES easy to translate, into low- level language. Java BYTECODE executed by interpreter.

37 37 BYTECODE is also interpreted within a browser. With most programming languages, you either COMPILE or INTERPRET a program so that you can run it on your computer.

38 38 The Java programming language is unusual in that a program is both compiled and interpreted. With the compiler, first you translate a program into an intermediate format called

39 39 JAVA BYTECODES the platform-independent codes interpreted by the interpreter on the Java platform. The interpreter parses and runs each Java BYTECODE instruction on the computer.

40 40 Compilation happens just once; interpretation occurs each time the program is executed.

41 41 The BYTECODES can be executed by only a Java Virtual Machine (JVM), which is usually implemented in software rather than hardware.

42 42 You can think of Java BYTECODES as the machine code instructions for the Java Virtual Machine.

43 43 Java BYTECODES help make (write once, run anywhere) possible.

44 44 It means that as long as a computer has a Java virtual machine (JVM), the same program written in the Java programming language can run on Unix, Linux, Windows 2000 or on a Solaris workstation.

45 45

46 46 To execute Java BYTECODES, the VM uses a CLASS LOADER to load the BYTECODES from a disk or a network. Each class file is checked by a BYTECODE VERIFIER

47 47 that ensures the class is formatted correctly and will not corrupt memory when it is executed. The execution unit of the VM is an INTERPRETER which interpret the bytecode.

48 48

49 49

50 50 A Platform is the hardware or software environment in which a program runs. We know about some of the most popular platforms like Windows 2000, Linux, Solaris, and MacOS.

51 51 Java Platform Components 1- The Java Virtual Machine (JVM) 2- The Java Application Programming Interface (Java API)

52 52 The JVM is the base for the Java platform and is ported onto various hardware-based platforms.

53 53 The Java API is a large collection of ready-made software components that provide many useful capabilities, such as graphical user interface (GUI) widgets.

54 54 The Java API is grouped into libraries of related classes and interfaces; these libraries are known as packages.

55 55

56 56 PHASE 1 (WRITE) Program is created in the editor(like Notpad) and stored on disk with an extension of.java (filename.java).

57 57 PHASE 2 (COMPILE) Compiler creates BYTECODES and stores them on disk by using an executable program (javac.exe).

58 58 The compiled BYTECODE file has an extension of.class. The filename.java produces another file filename.class.

59 59 Syntax: C:\> javac filename.java

60 60 PHASE 3 (LOAD) Class loader puts BYTECODES into memory before execution. There are two types of programs in Java

61 61 APPLICATIONS A program that is stored and executed from the user’s local computer. Applications are executed using the Java Interpreter with a utility “JAVA.EXE”.

62 62 APPLETS A small program that is stored on a remote computer (that is accessed via World Wide Web (WWW) Browser).

63 63 Applets are loaded from a remote computer into the browser of user’s local machine, executed in local browser and discarded when execution completes.

64 64 Applets also can be viewed by a utility called “APPLETVIEWER.EXE”

65 65 Applets (.class) files are embedded into HTML pages using Tag and that HTML page can be viewed in the browser or appletivewer.

66 66 Syntax for Applet Tag <Applet code=“filename.class” height=200 width=300>

67 67 Syntax for Application C:\> java filename.class

68 68 Syntax for Applet C:\> appletviewer filename.html

69 69

70 70 JDK is a complete set of tools for java development, testing, documentation, and execution of java programs and applets. It provides the followings important programs.

71 71 javacJava Compiler javaJava Interpreter javadoc Documentation Generator appletviewerApplet viewer

72 72 When you install the latest version of JDK which is JDK1.6 on C:\ drive, All these programs are available in the following path. C:\program files\jdk1.6.0_14\bin


Download ppt "1. 2 is high level programming language like C++, Visual Basic, developed by James Gosling and Patrick Naughton at Sun Microsystems in 1991."

Similar presentations


Ads by Google