Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to java


Published on

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

  • Be the first to like this

Introduction to java

  1. 1. Name : Muhammad Asif Subhani Email: Course Structure: Lectures: 2
  2. 2.      Attendance as per university policy. However, if you do decide to join, you are not allowed to leave the class before its completion without the permission of the instructor Drink food not allowed in class Use of cell phones and similar devices is not permissible during the class. Your phones should not be visible or heard during the class Automated tools to check for plagiarism
  3. 3. Quizzes (10%) Assignments (15%) Mid Term Exam (15%) Project (30%) Final Exam (30%)
  4. 4.      10-15 minutes duration Will cover assignments and material covered in the class Unannounced No make-ups We will be dropping some quizzes from the final grade
  5. 5.      Assignments are individual or may be in group. No late submissions I encourage you to discuss your assignments with your friends but no copying is allowed. Both the copier and the originator will get 0. 20% marks deduction on per day late submission. 100% Deduction on no submission.
  6. 6.   MIDTERM:A single midterm exam that will cover all material covered till the midterm. FINAL: Will cover the entire course. The final will contain tough programming tasks
  7. 7.    Project will be in group and the submission of project in deliverables. No late submission of project deliverables. Project deadline and other detail will be announced later.
  8. 8.            Introduction to Java Basic I/O concepts, String, Wrapper Classes, Collections, Streams OOP Concepts – Encapsulation, Inheritance, Polymorphism OOP in Java – Inheritance, Abstract superclasses, Interfaces, Inner classes, Packages. Exception Handling Building GUIs with Swing. Components, drawing, layouts, graphics Events and Event Handling Threads and concurrency- Threads, synchronization JDBC – Database Application Networking – Client Server Application Using 3rd party API
  9. 9.        Agile Development Project Management & Documentation Testing UML Diagrams Code Refactoring ,Design Pattern Version Control System Project Demos / Presentation
  10. 10.    Java as a second language course ◦ Teaches programming in Java for people who already know how to program in C or similar language The Java programming language is a high-level language that can be characterized by all of the following buzzwords: ◦ Simple ◦ Object oriented ◦ Distributed ◦ Multithreaded ◦ Dynamic ◦ Architecture neutral ◦ Portable ◦ High performance ◦ Robust ◦ Secure Pre-requisites ◦ Basic programming background (C/C++) ◦ Problem solving techniques ◦ Debugging skills
  11. 11.   The Java Language runs on a “Java Virtual Machine” The Java compiler (javac) compiles Java code into byte-code
  12. 12.   Java Development Kit (JDK) is an implementation of either one of the Java SE, Java EE or Java ME platforms released by Oracle Corporation The Java platform has two components: ◦ The Java Virtual Machine ◦ The Java Application Programming Interface (API)
  13. 13.      Development Tools: compiling(javac compiler), running, monitoring, debugging, and documenting (javadoc documentation )your applications. Application Programming Interface (API): The API provides the core functionality of the Java programming language.. It spans everything from basic objects, to networking and security, to XML generation and database access, and more. Deployment Technologies: Java Web Start software and Java Plug-In. User Interface Toolkits: The Swing and Java 2D toolkits. Integration Libraries: JDBC™ API, Java RMI
  14. 14. .java .jar/ .class .c/ .cpp Compiler JDK .jar/ .class Computer JVM Editor 1 0 1 0 1 101111101010 1 Computer .obj .exe 1 0 1 0 1 Computer
  15. 15.  Core language ◦ Ints, array, objects, loops and conditionals  Libraries ◦ This is where the power of Java really emerges  String, ArrayList, HashMap, String Tokenizer ◦ Networking, Graphics, Database connectivity, ◦ Re-use at it’s best (so far).
  16. 16.   Similar to C/C++ in syntax But eliminates several complexities of ◦ ◦ ◦ ◦ ◦   No operator overloading No direct pointer manipulation or pointer arithmetic No multiple inheritance No malloc() and free() – handles memory automatically Garbage Collector Lots more things which make Java more attractive. Avoid platform dependencies. Write once, run anywhere.
  17. 17. se/downloads/index.html
  18. 18. 1 2 3
  19. 19. C:>set path="c:programfilesJavajdk1.7.0_17bin" C:>set classpath=%classpath%;.;
  20. 20. Your first application, HelloWorldApp, will simply display the greeting "Hello world!". To create this program, you will:    Create a source file A source file contains code, written in the Java programming language, that you and other programmers can understand. You can use any text editor to create and edit source files. Compile the source file into a .class file The Java programming language compiler (javac) takes your source file and translates its text into instructions that the Java virtual machine can understand. The instructions contained within this file are known as bytecodes. Run the program The Java application launcher tool (java) uses the Java virtual machine to run your application.
  21. 21. class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); } }
  22. 22.         Save the code in a file with the name To do this in Notepad, first choose the File > Save As menu item. Then, in the Save As dialog box: Using the Save in combo box, specify the folder (directory) where you'll save your file. In this example, the directory is java on the C drive. In the File name text field, type "", including the quotation marks. From the Save as type combo box, choose Text Documents (*.txt). In the Encoding combo box, leave the encoding as ANSI. When you're finished, the dialog box should look like this. The Save As dialog just before you click Save. Now click Save, and exit Notepad.
  23. 23.
  24. 24.     Your first application, HelloWorldApp, will simply display the greeting "Hello World!" To create this program, you will: Create an IDE project When you create an IDE project, you create an environment in which to build and run your applications. Using IDE projects eliminates configuration issues normally associated with developing on the command line. You can build or run your application by choosing a single menu item within the IDE. Add code to the generated source file A source file contains code, written in the Java programming language, that you and other programmers can understand. As part of creating an IDE project, a skeleton source file will be automatically generated. You will then modify the source file to add the "Hello World!" message. Compile the source file into a .class file The IDE invokes the Java programming language compiler (javac), which takes your source file and translates its text into instructions that the Java virtual machine can understand. The instructions contained within this file are known as bytecodes. Run the program The IDE invokes the Java application launcher tool (java), which uses the Java virtual machine to run your application.
  25. 25. To create an IDE project: 1.Launch the NetBeans IDE. ◦ On Microsoft Windows systems, you can use the NetBeans IDE item in the Start menu. 2.In the NetBeans IDE, choose File | New Project.
  26. 26. 3.In the New Project wizard, expand the Java category and select Java Application as shown in the following figure:
  27. 27. 4.In the Name and Location page of the wizard, do the following (as shown in the figure below):  In the Project Name field, type Hello World App.  In the Create Main Class field, type helloworldapp.HelloWorldApp.  Leave the Set as Main Project checkbox selected. 5.Click Finish.
  28. 28. The project is created and opened in the IDE. You should see the following components:  The Projects window, which contains a tree view of the components of the project, including source files, libraries that your code depends on, and so on.  The Source Editor window with a file called HelloWorldApp open.  The Navigator window, which you can use to quickly navigate between elements within the selected class.
  29. 29. /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package helloworldapp; /** * The HelloWorldApp class implements an application that * simply prints "Hello World!" to standard output. */ public class HelloWorldApp { /** * @param args the command line arguments */ public static void main(String[] args) { System.out.println("Hello World!"); // Display the string. } }
  30. 30. 6.To compile your source file, choose Run | Build Main Project from the IDE's main menu.
  31. 31. 7.From the IDE's menu bar, choose Run | Run Main Project.
  32. 32.        Comments are ignored by the compiler but are useful to other programmers. The Java programming language supports three kinds of comments: /* text */ The compiler ignores everything from /* to */. /** documentation */ This indicates a documentation comment (doc comment, for short). The compiler ignores this kind of comment, just like it ignores comments that use /* and */. The javadoc tool uses doc comments when preparing automatically generated documentation. For more information on javadoc, see the Javadoc™ tool documentation . // text The compiler ignores everything from // to the end of the line.
  33. 33.    In the Java programming language, every application must contain a main method whose signature is: public static void main(String[] args) The modifiers public and static can be written in either order (public static or static public), but the convention is to use public static as shown above. You can name the argument anything you want, but most programmers choose "args" or "argv". The main method is similar to the main function in C and C++; it's the entry point for your application and will subsequently invoke all the other methods required by your program.
  34. 34.       The main method accepts a single argument: an array of elements of type String. public static void main(String[] args) This array is the mechanism through which the runtime system passes information to your application. For example: java MyApp arg1 arg2 Each string in the array is called a command-line argument. Command-line arguments let users affect the operation of the application without recompiling it. For example, a sorting program might allow the user to specify that the data be sorted in descending order with this commandline argument: -descending The "Hello World!" application ignores its command-line arguments, but you should be aware of the fact that such arguments do exist.