Introduction to java
Upcoming SlideShare
Loading in...5
×
 

Introduction to java

on

  • 271 views

 

Statistics

Views

Total Views
271
Views on SlideShare
271
Embed Views
0

Actions

Likes
0
Downloads
1
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Introduction to java Introduction to java Presentation Transcript

  • Name : Muhammad Asif Subhani Email: asif.subhani@umt.edu.pk Course Structure: Lectures: 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
  • Quizzes (10%) Assignments (15%) Mid Term Exam (15%) Project (30%) Final Exam (30%)
  •      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
  •      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.
  •   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
  •    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.
  •            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
  •        Agile Development Project Management & Documentation Testing UML Diagrams Code Refactoring ,Design Pattern Version Control System Project Demos / Presentation
  •    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
  •   The Java Language runs on a “Java Virtual Machine” The Java compiler (javac) compiles Java code into byte-code
  •   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)
  •      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
  • .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
  •  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).
  •   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.
  • http://www.oracle.com/technetwork/java/java se/downloads/index.html
  • 1 2 3
  • C:>set path="c:programfilesJavajdk1.7.0_17bin" C:>set classpath=%classpath%;.;
  • 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.
  • class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); } }
  •         Save the code in a file with the name HelloWorldApp.java. 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 "HelloWorldApp.java", 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.
  • http://www.oracle.com/technetwork/java/javase/downloads/jdk-7netbeans-download-432126.html
  •     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.
  • 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.
  • 3.In the New Project wizard, expand the Java category and select Java Application as shown in the following figure:
  • 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.
  • 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.
  • /* * 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. } }
  • 6.To compile your source file, choose Run | Build Main Project from the IDE's main menu.
  • 7.From the IDE's menu bar, choose Run | Run Main Project.
  •        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.
  •    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.
  •       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.