SlideShare a Scribd company logo
Programming in JAVA
BY
N.RUBA
ASST.PROF/DEPT. OF CA,
BON SECOURS COLLEGE FOR WOMEN,
THANJAVUR.
1
 Overview of Java Technology
 Java as a programming language
 Java as a platform
 Short history of the development of java
 Java as a new paradigm in programming
 Features of Java
 Comparing java and other languages
 Applications and Applets
CHAPTER-2
Introduction to Java Programming
2
 A program is a series of instructions that are carried out by a computer.
 Application programming is a programming process that is aimed at
developing an application.(e.g banking, railway .,etc)
 Systems programming- is the activity of writing, amending or extending
the operating system, which is a program that runs on the computer
hardware in order to allow other applications to be run.
Introduction 3
 Java is a general-purpose high-level object oriented programming language that
provides the following characteristics:
 Simple
 Object oriented
 Interpreted•
 Architecture-neutral
 Platform independent
 Multithread
 Dynamic
 High-performance
 Distributed
 Robust
 Secure.
Java as a programming language
4
 A programming language requires either a compiler or an interpreter to
translate a code written in high-level programming language (source code)
into its machine language (objectcode) equivalent.
 But, to run a Java program, Java uses a combination of compiler and
interpreter.
 The Java compiler translates the Java program into an intermediate code called
Java byte code.
 A Java interpreter is used to run the compiled Java byte code. This allows Java
programs to run on different platforms.
 A compiled Java byte code can be executed on any computer platform on
which the Java interpreter is installed.
 For each type of computer, a different Java interpreter is required to interpret
the Java byte code.
5
 Java is a strongly typed language. That means that every variable
(or expression) has a type associated with it and the type is
known at the time of compilation.
 In Java, data type conversions do not take place
implicitly.
 There are three kinds of Java program:
 Applications These are stand-alone programs that run on a
computer.
 Applets These are programs that run on a web browser.
Appletviewer is provided to ensure that these programs run
without a web browser.
 Servlets These are programs that run at the server side

6
JAVA as a compiler and Interpreter
Object code
Java Byte
code
interpreter
Java Source
code
Compiler
7
 A software and hardware environment in which a program runs is referred
to as a platform.
 Java platform that is compatible and executes on platforms based on
different hardwares.
 Java platform consists of
 Java Virtual Machine(JVM)
 Receives bytecode files and translates them into machine language(object code)
instructions.
 E.g Unix, linux & windows
 Java Applications Programming Interface(JavaAPI)
 Collection of software components
 API grouped in the form of packages
Java as a platform 8
 Java is a result of efforts of programmers in the early 1990s to develop a portable,
secure and scalable language to be used for communication between electronic
devices.
 A team of programmers led by James Gosling of Sun microsystems developed the first
version of Java called OAK.
 Java language was meant for programming the embedded systems in consumer
electronic devices
 Since the Oak trademark was already registered with some other organization, Sun
Microsystems renamed the language Java, in January 1995.
 During the period when Oak was being developed, the computer world witnessed the
emergence of the Internet. As Internet usage became widespread, the need for a
portable,secure programming language increased.
 Java fit the bill perfectly. Initially developed for use on different electronic devices, the
language was later adapted for Internet programming, Java met all the requirements
specified for web-based applications as it can be used to writeplatform-independent
code.
History of development of Java 9
 In 1995, Sun Microsystems released the first version of the Java Development Kit (JDK)and HotJava, a
Java-enabled browser.
 HotJava was capable of running Java applicationsin the form of Java Applets embedded in web pages, a
feature since taken up by browsers from Microsoft and Netscape. Java is often described as the World
Wide Web (www) programming language.
 From the second half of the 1990s, the popularity of Java increased considerably. An important
consequence of the evolution of Java is that it has grown into a full-scale development system.
 capable of being used for developing large applications that exist outside of the web (Internet)
environment that is, all kinds of program that run on a PC), including those that make extensive use of
networking to enable communication between programs.
 Sun Microsystems are now working to further refine and develop Java language.
In addition,they are also working on other Java tools and applications, Prominent among these are
thefollowing:
 Java Beans--the Java object component technology
 JavaServer-a complete web server application written in Java, supporting serviets.•
 JDBC-Java Database Connectivity, providing a Java-based interface to SQL databases.
 Java Workshop a Java programming environment for developing Java programs which isitself
written in Java.
 To get the latest updates on other Java tools and applications, readers can refer to the website of
Sun Microsystems-http://www.sun.com.
10
There are a number of other factors that are attributed to the rise in popularity of Java.
These include the following
 Familiarity of Java as a programming language to users of other popular languages,
notably C++ and Smalltalk: due to this factor, users find it simple and easy to relate
and comprehend.
 The Java development kit is offered free of cost
 This factor allows potential users to try out language with minimal start-up cost
 Its availability: Java is offered as freely downloadable software from the Sun
Microsystems website
 The software is also available on other websites
 Finally, its timing: Java gained popularity as it emerged at the right time when the
Internet was in its nascent stage and was all set to grow in popularity
Java as a new paradigm in programming
11
Features of Java
It is simple, it is highly robust, platform independent and portable
 Java is simple and Object Oriented Language
 Java is highly secure
 Allows to develop highly reliable software applications.
 Provides compile time checking and run time checking.
 Java makes memory management extremely simple
12
 Java compiler generates a byte code.
 Bytecode-special format
 Java byte code written in hexadecimal characters
 Byte code is completely platform- independent, only the interpreter and a few
native libraries need to be ported to get java run on a new computer or OS.
 The architectural –neutral and portable language platform of java is known as JVM-
Java Virtual Machine.
 Java shows a high performance
 Java is interpreted, threaded and dynamic
 Providing multi threading capability
 Multithreading in Java is a process of executing multiple
threads simultaneously.
 A thread is a lightweight sub-process, the smallest unit of processing.
Multiprocessing and multithreading, both are used to achieve multitasking.
13
 Java is dynamically linked
 Does not have an explicit link space.
 Java source code is divided into .java files
 Compiler complies these into .class files
 Other features of java – no pointers, all memory access is trusted
automatic memory allocation and deallocation
14
Comparing Java and other Languages
 Java is similar to C and C++, but is strongly typed
 Java is dynamically linked
 Java is case sensitive
 Java does not support pointer
 Java allows single inheritance
 Multiple inheritance can be achieved in java through interfaces
 Java is compiled and interpreted language
15
Applications and Applets
 Java program are compiled into applet or application
 Application are stand-alone program executed by virtual machine
 Applets are intended to be loaded into and interpreted by a browser, such
as Netscape or Internet explorer
 A byte code cannot be modified by a programmer
16
Java Applet
 Applet is a special type of program that is embedded in the webpage to generate the
dynamic content. It runs inside the browser and works at client side.
Advantage of Applet
 There are many advantages of applet. They are as follows:
 It works at client side so less response time.
 Secured
 It can be executed by browsers running under many platforms, including Linux, Windows,
Mac Os etc.
Drawback of Applet
 Plugin is required at client browser to execute applet.
How to run an Applet?
 There are two ways to run an applet
 By html file.
 By appletViewer tool (for testing purpose).
17
example of Applet by html file:
To execute the applet by html file, create an applet and compile it. After that create an
html file and place the applet code in html file. Now click the html file.
//First.java
import java.applet.Applet;
import java.awt.Graphics;
public class First extends Applet{
public void paint(Graphics g){
g.drawString("welcome",150,150);
}
}
Note: class must be public because its object is created by Java Plugin software that
resides on the browser.
18
myapplet.html
<html>
<body>
<applet code="First.class" width="300" height="300">
</applet>
</body>
</html>
 To execute the applet by html file, create an applet and compile it. After that create an html
file and place the applet code in html file. Now click the html file.
19
Simple example of Applet by appletviewer tool:
To execute the applet by appletviewer tool, create an applet that contains applet tag in comment and
compile it. After that run it by: appletviewer First.java. Now Html file is not required but it is for testing
purpose only.
//First.java
import java.applet.Applet;
import java.awt.Graphics;
public class First extends Applet{
public void paint(Graphics g){
g.drawString("welcome to applet",150,150);
}
}
/*
<applet code="First.class" width="300" height="300">
</applet>
*/
20
 To execute the applet by appletviewer tool, write in command prompt:
 c:>javac First.java
 c:>appletviewer First.java
21
 Special features of java program
 Access specifier
 Constructors
 Static
 The method main()
 The signature of the main method is
 Public staticvoid main(String args[])
22
Step 1:
Write a program on the notepad and save it with .java (for
example, DemoFile.java) extension.
class Demofile
{
public static void main(String args[]) {
System.out.println("Hello!");
System.out.println("Java");
}
}
23
Step 2:
Open Command Prompt.
Step 3:
Set the directory in which the .java file is saved. In our case, the .java
is saved in C:demo.
Step 4:
Use the javac command to compile the Java program. It generates a
.class file in the same folder. It also shows an error if any.
javac Demofile.java
step 5:
Use the following command to run the Java program:
c:> cd demo
c:> demo> javac Demofile.Java
c:> java Demofile
output:
Hello! Java
24
Thank you
25

More Related Content

What's hot (19)

DOCX
Software environment
Kinnudj Amee
 
PDF
Java Programming Basics
Rkrishna Mishra
 
DOCX
Software requirement
madhukarreddy007
 
PDF
perl-java
tutorialsruby
 
PPTX
C,c++,java,php,.net training institute in delhi, best training institute for ...
MCM COmpetitive Classes
 
PPTX
Features of java
Hitesh Kumar
 
PDF
(Ebook pdf) java programming language basics
Raffaella D'angelo
 
PPTX
A Comparison of .NET Framework vs. Java Virtual Machine
Abdelrahman Hosny
 
PDF
Java Programming
Prof. Dr. K. Adisesha
 
PPTX
Java
Snehal Shahane
 
PPTX
Structure programming – Java Programming – Theory
OXUS 20
 
PPT
Java features
myrajendra
 
PPTX
Presentación rs232 java
John Rojas
 
PPTX
Java (Part 2) unit 1
Dr. SURBHI SAROHA
 
PDF
J introtojava1-pdf
Emmanuel Alimpolos
 
PPTX
Core Java
NA
 
DOCX
JAVA First Day
Sher Singh Bardhan
 
PDF
JAVA Program Examples
Prof Chethan Raj C
 
Software environment
Kinnudj Amee
 
Java Programming Basics
Rkrishna Mishra
 
Software requirement
madhukarreddy007
 
perl-java
tutorialsruby
 
C,c++,java,php,.net training institute in delhi, best training institute for ...
MCM COmpetitive Classes
 
Features of java
Hitesh Kumar
 
(Ebook pdf) java programming language basics
Raffaella D'angelo
 
A Comparison of .NET Framework vs. Java Virtual Machine
Abdelrahman Hosny
 
Java Programming
Prof. Dr. K. Adisesha
 
Structure programming – Java Programming – Theory
OXUS 20
 
Java features
myrajendra
 
Presentación rs232 java
John Rojas
 
Java (Part 2) unit 1
Dr. SURBHI SAROHA
 
J introtojava1-pdf
Emmanuel Alimpolos
 
Core Java
NA
 
JAVA First Day
Sher Singh Bardhan
 
JAVA Program Examples
Prof Chethan Raj C
 

Similar to Features of java unit 1 (20)

PPT
Chapter 1 introduction to java technology
sshhzap
 
PPTX
Unit1- OOPJ Chapter-1 Object Oriented Programming JAVA.pptx
Divya573916
 
PPTX
JAVA ALL 5 MODULE NOTES.pptx
DrPreethiD1
 
PPT
Core Java Slides
Vinit Vyas
 
PPT
Java & J2EE Struts with Hibernate Framework
Mohit Belwal
 
PPT
Core java slides
Abhilash Nair
 
DOCX
java introduction.docx
vikasbagra9887
 
PPT
Java presentation
Karan Sareen
 
PPTX
Unit1 JAVA.pptx
RahulAnand111531
 
PPTX
Java Programming Tutorials Basic to Advanced 1
JALALUDHEENVK1
 
PPT
Java features
Madishetty Prathibha
 
PPTX
JAVA PROGRAMMING-Unit I - Final PPT.pptx
SuganthiDPSGRKCW
 
PDF
Core Java-1 (1).pdf
HaskellKohler1234
 
PDF
0f0cef_1dac552af56c4338ab0672859199e693.pdf
DeepakChaudhriAmbali
 
DOCX
Notes of java first unit
gowher172236
 
PPTX
JAVA FEATURES
shalinikarunakaran1
 
PDF
Introduction to Java Programming.pdf
AdiseshaK
 
PDF
Java Evolution-2.pdf
kumari36
 
PPTX
MODULE_1_The History and Evolution of Java.pptx
VeerannaKotagi1
 
PPT
Java2020 programming basics and fundamentals
swecsaleem
 
Chapter 1 introduction to java technology
sshhzap
 
Unit1- OOPJ Chapter-1 Object Oriented Programming JAVA.pptx
Divya573916
 
JAVA ALL 5 MODULE NOTES.pptx
DrPreethiD1
 
Core Java Slides
Vinit Vyas
 
Java & J2EE Struts with Hibernate Framework
Mohit Belwal
 
Core java slides
Abhilash Nair
 
java introduction.docx
vikasbagra9887
 
Java presentation
Karan Sareen
 
Unit1 JAVA.pptx
RahulAnand111531
 
Java Programming Tutorials Basic to Advanced 1
JALALUDHEENVK1
 
Java features
Madishetty Prathibha
 
JAVA PROGRAMMING-Unit I - Final PPT.pptx
SuganthiDPSGRKCW
 
Core Java-1 (1).pdf
HaskellKohler1234
 
0f0cef_1dac552af56c4338ab0672859199e693.pdf
DeepakChaudhriAmbali
 
Notes of java first unit
gowher172236
 
JAVA FEATURES
shalinikarunakaran1
 
Introduction to Java Programming.pdf
AdiseshaK
 
Java Evolution-2.pdf
kumari36
 
MODULE_1_The History and Evolution of Java.pptx
VeerannaKotagi1
 
Java2020 programming basics and fundamentals
swecsaleem
 
Ad

More from RubaNagarajan (19)

PPTX
Computer graphics-CRT.pptx
RubaNagarajan
 
PPTX
Matrix representation- CG.pptx
RubaNagarajan
 
PPTX
Personality development.pptx
RubaNagarajan
 
PPTX
TRANSFORMATION-CG.pptx
RubaNagarajan
 
PPTX
dda algorithm-cg.pptx
RubaNagarajan
 
PPTX
line attributes.pptx
RubaNagarajan
 
PPT
Java files and io streams
RubaNagarajan
 
PPTX
Java -Exception handlingunit-iv
RubaNagarajan
 
PPTX
Java Programming
RubaNagarajan
 
PPTX
Introduction to Java -unit-1
RubaNagarajan
 
PPTX
Constructors in C++
RubaNagarajan
 
PPTX
Risks in cc
RubaNagarajan
 
PPTX
Dreamweaver
RubaNagarajan
 
PPT
Working principles of internet
RubaNagarajan
 
PPT
Coreldraw
RubaNagarajan
 
PPT
C programming
RubaNagarajan
 
PPT
OPERATING SYSTEM
RubaNagarajan
 
PDF
Virtualization in cloud computing
RubaNagarajan
 
PDF
Cloud computing technology
RubaNagarajan
 
Computer graphics-CRT.pptx
RubaNagarajan
 
Matrix representation- CG.pptx
RubaNagarajan
 
Personality development.pptx
RubaNagarajan
 
TRANSFORMATION-CG.pptx
RubaNagarajan
 
dda algorithm-cg.pptx
RubaNagarajan
 
line attributes.pptx
RubaNagarajan
 
Java files and io streams
RubaNagarajan
 
Java -Exception handlingunit-iv
RubaNagarajan
 
Java Programming
RubaNagarajan
 
Introduction to Java -unit-1
RubaNagarajan
 
Constructors in C++
RubaNagarajan
 
Risks in cc
RubaNagarajan
 
Dreamweaver
RubaNagarajan
 
Working principles of internet
RubaNagarajan
 
Coreldraw
RubaNagarajan
 
C programming
RubaNagarajan
 
OPERATING SYSTEM
RubaNagarajan
 
Virtualization in cloud computing
RubaNagarajan
 
Cloud computing technology
RubaNagarajan
 
Ad

Recently uploaded (20)

PPTX
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
community health nursing question paper 2.pdf
Prince kumar
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 

Features of java unit 1

  • 1. Programming in JAVA BY N.RUBA ASST.PROF/DEPT. OF CA, BON SECOURS COLLEGE FOR WOMEN, THANJAVUR. 1
  • 2.  Overview of Java Technology  Java as a programming language  Java as a platform  Short history of the development of java  Java as a new paradigm in programming  Features of Java  Comparing java and other languages  Applications and Applets CHAPTER-2 Introduction to Java Programming 2
  • 3.  A program is a series of instructions that are carried out by a computer.  Application programming is a programming process that is aimed at developing an application.(e.g banking, railway .,etc)  Systems programming- is the activity of writing, amending or extending the operating system, which is a program that runs on the computer hardware in order to allow other applications to be run. Introduction 3
  • 4.  Java is a general-purpose high-level object oriented programming language that provides the following characteristics:  Simple  Object oriented  Interpreted•  Architecture-neutral  Platform independent  Multithread  Dynamic  High-performance  Distributed  Robust  Secure. Java as a programming language 4
  • 5.  A programming language requires either a compiler or an interpreter to translate a code written in high-level programming language (source code) into its machine language (objectcode) equivalent.  But, to run a Java program, Java uses a combination of compiler and interpreter.  The Java compiler translates the Java program into an intermediate code called Java byte code.  A Java interpreter is used to run the compiled Java byte code. This allows Java programs to run on different platforms.  A compiled Java byte code can be executed on any computer platform on which the Java interpreter is installed.  For each type of computer, a different Java interpreter is required to interpret the Java byte code. 5
  • 6.  Java is a strongly typed language. That means that every variable (or expression) has a type associated with it and the type is known at the time of compilation.  In Java, data type conversions do not take place implicitly.  There are three kinds of Java program:  Applications These are stand-alone programs that run on a computer.  Applets These are programs that run on a web browser. Appletviewer is provided to ensure that these programs run without a web browser.  Servlets These are programs that run at the server side  6
  • 7. JAVA as a compiler and Interpreter Object code Java Byte code interpreter Java Source code Compiler 7
  • 8.  A software and hardware environment in which a program runs is referred to as a platform.  Java platform that is compatible and executes on platforms based on different hardwares.  Java platform consists of  Java Virtual Machine(JVM)  Receives bytecode files and translates them into machine language(object code) instructions.  E.g Unix, linux & windows  Java Applications Programming Interface(JavaAPI)  Collection of software components  API grouped in the form of packages Java as a platform 8
  • 9.  Java is a result of efforts of programmers in the early 1990s to develop a portable, secure and scalable language to be used for communication between electronic devices.  A team of programmers led by James Gosling of Sun microsystems developed the first version of Java called OAK.  Java language was meant for programming the embedded systems in consumer electronic devices  Since the Oak trademark was already registered with some other organization, Sun Microsystems renamed the language Java, in January 1995.  During the period when Oak was being developed, the computer world witnessed the emergence of the Internet. As Internet usage became widespread, the need for a portable,secure programming language increased.  Java fit the bill perfectly. Initially developed for use on different electronic devices, the language was later adapted for Internet programming, Java met all the requirements specified for web-based applications as it can be used to writeplatform-independent code. History of development of Java 9
  • 10.  In 1995, Sun Microsystems released the first version of the Java Development Kit (JDK)and HotJava, a Java-enabled browser.  HotJava was capable of running Java applicationsin the form of Java Applets embedded in web pages, a feature since taken up by browsers from Microsoft and Netscape. Java is often described as the World Wide Web (www) programming language.  From the second half of the 1990s, the popularity of Java increased considerably. An important consequence of the evolution of Java is that it has grown into a full-scale development system.  capable of being used for developing large applications that exist outside of the web (Internet) environment that is, all kinds of program that run on a PC), including those that make extensive use of networking to enable communication between programs.  Sun Microsystems are now working to further refine and develop Java language. In addition,they are also working on other Java tools and applications, Prominent among these are thefollowing:  Java Beans--the Java object component technology  JavaServer-a complete web server application written in Java, supporting serviets.•  JDBC-Java Database Connectivity, providing a Java-based interface to SQL databases.  Java Workshop a Java programming environment for developing Java programs which isitself written in Java.  To get the latest updates on other Java tools and applications, readers can refer to the website of Sun Microsystems-http://www.sun.com. 10
  • 11. There are a number of other factors that are attributed to the rise in popularity of Java. These include the following  Familiarity of Java as a programming language to users of other popular languages, notably C++ and Smalltalk: due to this factor, users find it simple and easy to relate and comprehend.  The Java development kit is offered free of cost  This factor allows potential users to try out language with minimal start-up cost  Its availability: Java is offered as freely downloadable software from the Sun Microsystems website  The software is also available on other websites  Finally, its timing: Java gained popularity as it emerged at the right time when the Internet was in its nascent stage and was all set to grow in popularity Java as a new paradigm in programming 11
  • 12. Features of Java It is simple, it is highly robust, platform independent and portable  Java is simple and Object Oriented Language  Java is highly secure  Allows to develop highly reliable software applications.  Provides compile time checking and run time checking.  Java makes memory management extremely simple 12
  • 13.  Java compiler generates a byte code.  Bytecode-special format  Java byte code written in hexadecimal characters  Byte code is completely platform- independent, only the interpreter and a few native libraries need to be ported to get java run on a new computer or OS.  The architectural –neutral and portable language platform of java is known as JVM- Java Virtual Machine.  Java shows a high performance  Java is interpreted, threaded and dynamic  Providing multi threading capability  Multithreading in Java is a process of executing multiple threads simultaneously.  A thread is a lightweight sub-process, the smallest unit of processing. Multiprocessing and multithreading, both are used to achieve multitasking. 13
  • 14.  Java is dynamically linked  Does not have an explicit link space.  Java source code is divided into .java files  Compiler complies these into .class files  Other features of java – no pointers, all memory access is trusted automatic memory allocation and deallocation 14
  • 15. Comparing Java and other Languages  Java is similar to C and C++, but is strongly typed  Java is dynamically linked  Java is case sensitive  Java does not support pointer  Java allows single inheritance  Multiple inheritance can be achieved in java through interfaces  Java is compiled and interpreted language 15
  • 16. Applications and Applets  Java program are compiled into applet or application  Application are stand-alone program executed by virtual machine  Applets are intended to be loaded into and interpreted by a browser, such as Netscape or Internet explorer  A byte code cannot be modified by a programmer 16
  • 17. Java Applet  Applet is a special type of program that is embedded in the webpage to generate the dynamic content. It runs inside the browser and works at client side. Advantage of Applet  There are many advantages of applet. They are as follows:  It works at client side so less response time.  Secured  It can be executed by browsers running under many platforms, including Linux, Windows, Mac Os etc. Drawback of Applet  Plugin is required at client browser to execute applet. How to run an Applet?  There are two ways to run an applet  By html file.  By appletViewer tool (for testing purpose). 17
  • 18. example of Applet by html file: To execute the applet by html file, create an applet and compile it. After that create an html file and place the applet code in html file. Now click the html file. //First.java import java.applet.Applet; import java.awt.Graphics; public class First extends Applet{ public void paint(Graphics g){ g.drawString("welcome",150,150); } } Note: class must be public because its object is created by Java Plugin software that resides on the browser. 18
  • 19. myapplet.html <html> <body> <applet code="First.class" width="300" height="300"> </applet> </body> </html>  To execute the applet by html file, create an applet and compile it. After that create an html file and place the applet code in html file. Now click the html file. 19
  • 20. Simple example of Applet by appletviewer tool: To execute the applet by appletviewer tool, create an applet that contains applet tag in comment and compile it. After that run it by: appletviewer First.java. Now Html file is not required but it is for testing purpose only. //First.java import java.applet.Applet; import java.awt.Graphics; public class First extends Applet{ public void paint(Graphics g){ g.drawString("welcome to applet",150,150); } } /* <applet code="First.class" width="300" height="300"> </applet> */ 20
  • 21.  To execute the applet by appletviewer tool, write in command prompt:  c:>javac First.java  c:>appletviewer First.java 21
  • 22.  Special features of java program  Access specifier  Constructors  Static  The method main()  The signature of the main method is  Public staticvoid main(String args[]) 22
  • 23. Step 1: Write a program on the notepad and save it with .java (for example, DemoFile.java) extension. class Demofile { public static void main(String args[]) { System.out.println("Hello!"); System.out.println("Java"); } } 23
  • 24. Step 2: Open Command Prompt. Step 3: Set the directory in which the .java file is saved. In our case, the .java is saved in C:demo. Step 4: Use the javac command to compile the Java program. It generates a .class file in the same folder. It also shows an error if any. javac Demofile.java step 5: Use the following command to run the Java program: c:> cd demo c:> demo> javac Demofile.Java c:> java Demofile output: Hello! Java 24