00 intro to java


Published on

Published in: Technology, Education
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

00 intro to java

  1. 1. Engr. Dheya Abdullah JAVA Overview
  2. 2. What will this talk cover? <ul><li>Outline </li></ul><ul><ul><li>Brief History </li></ul></ul><ul><ul><li>How Java Work </li></ul></ul><ul><ul><li>Java Virtual Machine JVM </li></ul></ul><ul><ul><li>JVM Architecture </li></ul></ul><ul><ul><li>OOP Concepts </li></ul></ul><ul><ul><li>Java features </li></ul></ul><ul><ul><li>Java Libraries </li></ul></ul><ul><ul><li>What is Java good for </li></ul></ul><ul><ul><li>Hello world program in Java </li></ul></ul><ul><ul><li>Java Applet </li></ul></ul>
  3. 3. What is Java? <ul><li>History </li></ul><ul><ul><li>Started in (1991) as a small language for consumer electronics (toasters, microwave ovens… etc. ) by James Gosling with the name of OAK. </li></ul></ul><ul><ul><li>Java is developed by Sun Microsystems and officially released in 1995. </li></ul></ul><ul><ul><li>The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. </li></ul></ul>
  4. 4. How does Java work? <ul><li>Java source code is compiled into machine independent “bytecodes” </li></ul><ul><li>The bytecodes can be run directly by an interpreter </li></ul><ul><li>The bytecodes can be converted to machine code and executed (“ Just in Time (JIT)” compilation). </li></ul><ul><li>An optimizing interpreter can dynamically identify program “hotspots” and create code optimized for the specific machine/environment. </li></ul>
  5. 5. Java Virtual Machine JVM <ul><li>its just a program that runs in the host computer. It receives bytecodes and gives machine-code understandable to the host computer </li></ul><ul><li>So its evident that we have a single Compiler but multiple JVMs (JVM for Windows, JVM for Unix, JVM for MacOS). </li></ul><ul><li>Any new system that will appear in future, java will make a new JVM for it so java supports unknown future machines. </li></ul>
  6. 6. JVM Architecture <ul><li>Class Loader : loads the java programs (bytecodes) </li></ul><ul><li>Bytecodes verifier : verifies that bytecode has not been modified since it last compilation. </li></ul><ul><li>Interpreter : this is the actual part that translates the bytecode into a code understandable/executable by the host machine. </li></ul><ul><li>Other parts not shown in this figure are </li></ul><ul><li>Security manager </li></ul><ul><li>Library classes </li></ul><ul><li>JIT (Just in time compiler) </li></ul>
  7. 7. Main OOP Concepts <ul><li>OOP is a set of concepts for organizing and arranging the code in a program its not a programming language. </li></ul><ul><li>Main concepts of OOP: </li></ul><ul><ul><li>Class ( a structure that contains variables and functions together ) </li></ul></ul><ul><ul><li>Object (an instance of a class) </li></ul></ul><ul><ul><li>Encapsulation. </li></ul></ul><ul><ul><li>Inheritance. </li></ul></ul><ul><ul><li>Polymorphism. </li></ul></ul><ul><li>Coming lectures will make these concepts more clear. </li></ul>
  8. 8. Java Features <ul><li>Simple </li></ul><ul><ul><li>Java in similar to C++ in its syntax, but it is simpler than C++ in developing applications because its rich in its libraries (Java has a huge amount of ready made functions so programmer doesn't need to rewrite them) </li></ul></ul><ul><li>Object Orientated </li></ul><ul><ul><li>Java implements OOP concepts more so than C++. </li></ul></ul><ul><ul><li>In C++ programmer has the option to go for Procedural way of programming or to Object Oriented way of programming its optional. </li></ul></ul><ul><ul><li>But in Java its purely OOP programmer have to follow OOP concepts to develop applications in Java no other option. </li></ul></ul><ul><li>Distributed </li></ul><ul><ul><li>Distributed systems is an environment where single application can run on multiple computers connected in a network. </li></ul></ul><ul><ul><li>Java supports Internet protocols, URL’s, HTTP etc. </li></ul></ul><ul><ul><li>Support for distributed objects, RMI, CORBA etc. </li></ul></ul><ul><li>Robust </li></ul><ul><ul><li>Difficult to create memory leaks, go beyond the end of an array. </li></ul></ul>
  9. 9. Java Features Cont. <ul><li>Secure </li></ul><ul><ul><li>Bytecodes “verifier”, checks the program before it is executed. </li></ul></ul><ul><li>Platform independent / Portable </li></ul><ul><ul><li>JVM accepts only bytecodes and generates host’s machine-code. </li></ul></ul><ul><li>Interpreter / Compiler </li></ul><ul><ul><li>Java default Translator is an interpreter. </li></ul></ul><ul><ul><li>Java also has a compiler known as JIT Just In Time compiler. </li></ul></ul><ul><li>High Performance </li></ul><ul><ul><li>With JIT compiler still several times slower than native C++. But with Sun Optimizing Interpreter, java programs can run faster than C++ program. </li></ul></ul><ul><li>Multithreaded </li></ul><ul><ul><li>Java has direct support for multithreading (c.f. subprocesses) </li></ul></ul><ul><li>Dynamic </li></ul><ul><ul><li>Libraries can change without recompiling programs that use them. </li></ul></ul>
  10. 10. Java Libraries (API’s) <ul><li>In addition to the core language, java has additional classes: </li></ul><ul><ul><li>AWT - Basic GUI (Forms, Buttons, Textbox, Dropdown-box, Radio/Check) </li></ul></ul><ul><ul><li>SWING - Enhanced GUI toolkit </li></ul></ul><ul><ul><li>2D – Drawings (lines, shapes such as circle, square…etc ), Transformations, pattern fill, textures etc. </li></ul></ul><ul><ul><li>JDBC - Standard Interface between Java and SQL databases </li></ul></ul><ul><ul><li>ODMG binding - Standard Interface to Object databases </li></ul></ul><ul><ul><li>RMI + CORBA - Remote procedure calls between distributed Java applications, and between Java and other languages </li></ul></ul><ul><ul><li>BEANS - Java based components, plug commercial components into your applications. </li></ul></ul><ul><ul><li>Media (audio, video etc.), Share (e.g. whiteboards), Animation , Telephony , 3D (developed by SUN and SGI), cryptography , server . </li></ul></ul>
  11. 11. What is Java Good For? <ul><li>Stand Alone Applications </li></ul><ul><ul><li>GUI based applications </li></ul></ul><ul><li>Database programming </li></ul><ul><ul><li>SQL databases using JDBC </li></ul></ul><ul><ul><li>Object databases using ODMG binding </li></ul></ul><ul><li>Web Applets </li></ul><ul><li>Java Servlets </li></ul><ul><li>Distributed client-server applications </li></ul><ul><ul><li>Using TCPIP + RMI + CORBA </li></ul></ul><ul><li>Graphics applications </li></ul><ul><ul><li>2D and 3D </li></ul></ul>
  12. 12. Java Program Types <ul><li>Java can make two type of program </li></ul><ul><ul><li>Application (a full standalone program such C++ language programs that can run on any OS). </li></ul></ul><ul><ul><li>Applets (a light weight program that runs within Internet Browsers its usually a part of web pages) </li></ul></ul>
  13. 13. Hello World in Java <ul><li>This is how Java Application looks like </li></ul>
  14. 14. Java Applets <ul><li>Java Applets : are programs designed to run inside a web browser. </li></ul><ul><li>Applets loaded from the internet are run inside a “sandbox” which restricts what they can do: </li></ul><ul><ul><li>No Access to local filesystem </li></ul></ul><ul><ul><li>Can only open network connections with the site they came from </li></ul></ul><ul><li>Problems (the need for applet) </li></ul><ul><ul><li>Complex programs can be large and hence slow to download </li></ul></ul><ul><ul><li>Each browser has subtle differences. </li></ul></ul>
  15. 15. Assignment #1 <ul><li>Objective : This Assignment will help students to compare two languages to understand common concepts and unique features of each language. </li></ul><ul><li>You can compare any two languages, choose one of these titles and work on it. </li></ul><ul><ul><li>Java vs. VB.Net </li></ul></ul><ul><ul><li>Java vs. C++ </li></ul></ul><ul><li>The comparison should contain at least six differences with three lines explanation of each difference. </li></ul><ul><li>Submission Timing: </li></ul><ul><li>the assignment should be submitted after one complete week (2 nd lecture next week). </li></ul><ul><li>These assignments are Marked assignment. </li></ul><ul><li>The Solution will look like </li></ul>Hint: use Google.com to get the material and then summarize it in your words Java C++ Pure OOP language: Java is pure OOP language because it allow programmer to write code only in classes and objects. Hybrid language: C++ allows programmer to write code in structural way using functions or OOP way using classes and objects (OOP is optional). … .. …… ..
  16. 16. Evaluation, Rules & Instructions: <ul><li>Evaluation : </li></ul><ul><ul><li>Final exam will be taken at end of semester with 35% weight. </li></ul></ul><ul><ul><li>Mid semester exam will be taken at 6th week with 20% weight. </li></ul></ul><ul><ul><li>Assignments, Class interaction, Lab performance and attendance 15% weight. </li></ul></ul><ul><ul><li>Announced short Quizzes will be taken with 10% weight. </li></ul></ul><ul><ul><li>Semester Project with 20% weight. </li></ul></ul><ul><li>  Road map to pass JAVA course: </li></ul><ul><ul><li>Attend Classes regularly and Do lab work . </li></ul></ul><ul><ul><li>Submit mini assignments. </li></ul></ul><ul><ul><li>Don’t miss quizzes. </li></ul></ul><ul><ul><li>Attend mid-exam and final exam. </li></ul></ul><ul><li>Rules & Instructions: </li></ul><ul><ul><li>End of each week (2 nd lecture of the week) a marked assignment will be given and it will be collected next week 1 st lecture. </li></ul></ul><ul><ul><li>First lecture of the next week a short quiz will be taken from last week topics and assignment. </li></ul></ul>
  17. 17. More Information <ul><li>Web Sites </li></ul><ul><ul><li>http://www.javasoft.com </li></ul></ul><ul><ul><ul><li>Sun’s home page for Java </li></ul></ul></ul><ul><ul><li>http://www.javasoft.com/books/Series/Tutorial/index.html </li></ul></ul><ul><ul><li>http://www.gamelan.com/ </li></ul></ul><ul><ul><ul><li>Huge library of Java applets and applications </li></ul></ul></ul><ul><ul><li>http://www.javaworld.com </li></ul></ul><ul><ul><li>http://www.javareport.com </li></ul></ul><ul><ul><ul><li>JavaWorld/Java Report (magazines) </li></ul></ul></ul><ul><ul><li>http://www.microsoft.com/visualj </li></ul></ul><ul><ul><ul><li>Visual J++ </li></ul></ul></ul><ul><li>Books </li></ul><ul><li>Text Book: </li></ul><ul><li>Java Software Soultions </li></ul><ul><li>Foundations of program design 6 th edition, Lewis & Loftus, Pearson. </li></ul><ul><li>Reference Book: </li></ul><ul><li>John Zukowski, Mastering Java 2 , Sybex. </li></ul>
  18. 18. Conclusion <ul><li>If you are still using: </li></ul><ul><ul><li>Fortran, C, C++, Perl, CGI, SQLPlus, Rexx, IDA etc. </li></ul></ul><ul><li>you could save yourself a lot of time and effort by switching to: </li></ul>