SlideShare a Scribd company logo
Introduction to java
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
Introduction to java




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.
Introduction to java
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.

More Related Content

PPTX
Chapter 2.1
DOCX
Unit of competency
PPTX
21. Java High Quality Programming Code
PPT
Core java slides
PPT
PDF
Java notes
PPTX
01. Introduction to programming with java
PDF
Java basics notes
Chapter 2.1
Unit of competency
21. Java High Quality Programming Code
Core java slides
Java notes
01. Introduction to programming with java
Java basics notes

What's hot (19)

PDF
JAVA Program Examples
PPT
Classes and Objects
PPT
PPTX
Introduction to java
PPTX
Training on java niit (sahil gupta 9068557926)
PPSX
Java Semimar Slide (Cetpa)
PPT
Chapter 1 introduction to java technology
DOCX
JAVA First Day
PPTX
Introducción a la progrogramación orientada a objetos con Java
PPTX
Java Notes
DOCX
Notes of java first unit
PPT
Java essential notes
PPTX
01. Introduction to Programming
PPT
Introduction to Java Programming, Basic Structure, variables Data type, input...
PPTX
Programming in Java
PPT
1 Introduction To Java Technology
PPTX
Installing JDK and first java program
PDF
Introduction to java technology
JAVA Program Examples
Classes and Objects
Introduction to java
Training on java niit (sahil gupta 9068557926)
Java Semimar Slide (Cetpa)
Chapter 1 introduction to java technology
JAVA First Day
Introducción a la progrogramación orientada a objetos con Java
Java Notes
Notes of java first unit
Java essential notes
01. Introduction to Programming
Introduction to Java Programming, Basic Structure, variables Data type, input...
Programming in Java
1 Introduction To Java Technology
Installing JDK and first java program
Introduction to java technology
Ad

Viewers also liked (15)

PPT
Introduction to java
PPTX
Military Police Host Nation Policing Simulation: A Case Study into Designing ...
PDF
Introduction to basics of java
PDF
History of java
PPT
The Evolution of Java
PPSX
Basic of Java Netbeans
PPTX
Ppt on java basics1
PPTX
Fundamentals of JAVA
PPTX
about java
PPTX
Introduction to Java
PPTX
Evolution of java By Abbas khan
PDF
Java tutorial
PPTX
Introduction to java
PPTX
Java programming course for beginners
PPT
Java tutorial PPT
Introduction to java
Military Police Host Nation Policing Simulation: A Case Study into Designing ...
Introduction to basics of java
History of java
The Evolution of Java
Basic of Java Netbeans
Ppt on java basics1
Fundamentals of JAVA
about java
Introduction to Java
Evolution of java By Abbas khan
Java tutorial
Introduction to java
Java programming course for beginners
Java tutorial PPT
Ad

Similar to Introduction to java (20)

PDF
Java lab1 manual
PPTX
Java Programming Tutorials Basic to Advanced 1
PPT
R:\ap java\class slides\chapter 1\1 2 java development
PPT
1 2 java development
PPT
Javalecture 1
PPT
Java introduction
PPTX
JAVA PROGRAMING NOTE FOR BEGINNERS 20242
PPTX
Curso de Programación Java Básico
PPT
Introduction to Software Development
PDF
Core java introduction
PPSX
Java Semimar Slide (Cetpa)
PDF
java 1 new.pdf
PDF
Java programming language basics
PPT
OOPM Introduction.ppt
PDF
J introtojava1-pdf
PDF
Introduction to Java Programming.pdf
PDF
(Ebook pdf) java programming language basics
PPTX
1_Introduction to Java.pptx java programming
PPTX
Chapter 1.3
PDF
Java basics notes
Java lab1 manual
Java Programming Tutorials Basic to Advanced 1
R:\ap java\class slides\chapter 1\1 2 java development
1 2 java development
Javalecture 1
Java introduction
JAVA PROGRAMING NOTE FOR BEGINNERS 20242
Curso de Programación Java Básico
Introduction to Software Development
Core java introduction
Java Semimar Slide (Cetpa)
java 1 new.pdf
Java programming language basics
OOPM Introduction.ppt
J introtojava1-pdf
Introduction to Java Programming.pdf
(Ebook pdf) java programming language basics
1_Introduction to Java.pptx java programming
Chapter 1.3
Java basics notes

Recently uploaded (20)

PDF
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
PDF
Chapter 2 Digital Image Fundamentals.pdf
PDF
Modernizing your data center with Dell and AMD
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
Smarter Business Operations Powered by IoT Remote Monitoring
PDF
Sensors and Actuators in IoT Systems using pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
KodekX | Application Modernization Development
PDF
ai-archetype-understanding-the-personality-of-agentic-ai.pdf
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
PDF
REPORT: Heating appliances market in Poland 2024
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
PPTX
Belt and Road Supply Chain Finance Blockchain Solution
PDF
Google’s NotebookLM Unveils Video Overviews
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
Chapter 2 Digital Image Fundamentals.pdf
Modernizing your data center with Dell and AMD
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Transforming Manufacturing operations through Intelligent Integrations
Smarter Business Operations Powered by IoT Remote Monitoring
Sensors and Actuators in IoT Systems using pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
NewMind AI Weekly Chronicles - August'25 Week I
Understanding_Digital_Forensics_Presentation.pptx
Chapter 3 Spatial Domain Image Processing.pdf
KodekX | Application Modernization Development
ai-archetype-understanding-the-personality-of-agentic-ai.pdf
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
REPORT: Heating appliances market in Poland 2024
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
Belt and Road Supply Chain Finance Blockchain Solution
Google’s NotebookLM Unveils Video Overviews

Introduction to java

  • 2. Name : Muhammad Asif Subhani Email: [email protected] Course Structure: Lectures: 2
  • 3.      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
  • 4. Quizzes (10%) Assignments (15%) Mid Term Exam (15%) Project (30%) Final Exam (30%)
  • 5.      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
  • 6.      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.
  • 7.   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
  • 8.    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.
  • 9.            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
  • 10.        Agile Development Project Management & Documentation Testing UML Diagrams Code Refactoring ,Design Pattern Version Control System Project Demos / Presentation
  • 11.    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
  • 12.   The Java Language runs on a “Java Virtual Machine” The Java compiler (javac) compiles Java code into byte-code
  • 14.   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)
  • 15.      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
  • 17.  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).
  • 18.   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.
  • 20. 1 2 3
  • 22. 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.
  • 23. class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); } }
  • 24.         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.
  • 27.     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.
  • 28. 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.
  • 29. 3.In the New Project wizard, expand the Java category and select Java Application as shown in the following figure:
  • 30. 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.
  • 31. 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.
  • 32. /* * 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. } }
  • 33. 6.To compile your source file, choose Run | Build Main Project from the IDE's main menu.
  • 34. 7.From the IDE's menu bar, choose Run | Run Main Project.
  • 35.        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.
  • 36.    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.
  • 37.       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.