SlideShare a Scribd company logo
1 of 22
A little cup of Java-coffee
Priyanka Gupta
CSE Dept.
Mcsgoc
Todayโ€™s session
โ€ข Part-1) Java overview
โ€“ What java is
โ€“ Java features
โ€“ Javaโ€™s cross-platform
โ€ข Part-2) two simple and typical java programs
โ€“ A stand-lone java and its running
โ€“ A applet and its running
Part-one
โ€ข Java overview
What Java is
โ€ข Java is an โ€œeasyโ€ programming language,
โ€“ just a tool like C++, VB, โ€ฆand English. Somehow a
language tool itself is not so complex.
โ€ข Java works for internet project(mainly), and apply
โ€œ3-tired architectureโ€, coding on the server-side
โ€“ So besides Java language knowledge, we need to learn
lots of thing about telecommunication on WEB, to
finish a real-time project.
What Java is(continue)
โ€ข Java applies Object-Oriented Tech.
โ€“ Java is not so difficulty, though OOP is. A java
expert must be an OOP expert.
โ€ข Java is slower than C++ ( 3-5 times), Javaโ€™s
database function is slower than VB.
โ€ข Java is very portable: cross-platform
Javaโ€™s Features
โ€ข Simple
Java omits many rarely used, poorly understood, confusing
features of C++. Say : No Pointer! No dynamic delete.
โ€ข Object Oriented
Object โ€“oriented design is a technology that focuses design
on the data (object) and on the interfaces to it.
Letโ€™s say, everything is an object, everything will
become a class in Java. Every java program, in top-
level view, is classes.
Javaโ€™s Features(continue)
โ€ข Robust
The single biggest difference between Java
and C/C++ is that Java has โ€œa inner safe
pointer-modelโ€, therefore it eliminates the
possibility of overwriting memory and corrupting
data, so programmers feel very safe in coding.
Javaโ€™s Features(continue)
โ€ข GUI [Java-Swing]
For some reason, Sun believe their java-swing
is very important, so they always put it in their
certificate-tests.
โ€ข Multi-threaded
โ€ข Secure [ Exception handling ]
โ€ข Dynamic [ for Server-side coding]
Javaโ€™s cross-platform
โ€ข Interpreted Execute: cross-platform
why: For cross-platform purpose. Once coding, run anywhere.
The Java interpreter ( java.exe and its javaVirtualMachine) can
execute compiled Java-byte-codes(Xxx.class) directly on any machine to
which the interpreter has been ported.
How: ( eg. Dos command line style)
- Edit source code โ€œdemo.javaโ€ , by notepad/or other IDE tools
- Compile ( javac.exe ) โ€œdemo.javaโ€๏ƒ  javac Demo.java ๏ƒ  Java byte
codes, namely, Demo.class
- Execute (Interpreted Execute) java Demo
โ€ข Speed issue AND new solutions: java is slower than c++ in running.
however, by now, there are some new technology of Java compiler, such
as โ€œJust-in-timeโ€, and โ€œHotSpot adaptive Compilerโ€. They make java
very faster than before.
Java: Run in Virtual Cpu
:cross-platfrom
Demo.java๏ƒ  Compile ๏ƒ Demo.class๏ƒ  link๏ƒ  xxx.class
Source-code โ€œjavacโ€ byte-code files bytecode
program
๏ƒ interpretedly run on VM |--๏ƒ  Intel CPU
(virtual CPU: JSDK ) |--๏ƒ  โ€ฆ CPU
|--๏ƒ  Apple CPU
Part-2 2 samples
โ€ข How many kinds of java programs ?
โ€ข Demo-1: Stand-lone sample
โ€ข Demo-2: an Applet sample
How many kinds of Java Programs?
โ€ข Un-network app.: (1)Standalone Java program (today)
โ€ข Network app: non-standalone Java program
Internet: (2)Applet , (today)
(3)servlet
(4)JavaBean classes
Intranet: (5)EJB ( EnterpriseJavaBean ),
(6)RMI, etc
Standalone Java Program
โ€ข The main() method
public static void main(String args[]){
...
}
public--- the interpreter can call it
static ----It is a static method belonging to the class
void -----It does not return a value
String----It always has an array of String objects as its formal parameter.
the array contains any arguments passed to the program on the
command line
the source fileโ€™s name must match the class name which main method is
in
Java program
1 // Fig. 2.1: Welcome1.java
2 // A first program in Java
3
4 public class Welcome1 {
5 public static void main( String args[] )
6 {
7 System.out.println( "Welcome to Java Programming!" );
8 }
Welcome to Java Programming!
9 }
Java program
1 // Fig. 2.1: Welcome1.java
2 // A first program in Java
3
4 public class Welcome1 {
5 public static void main( String args[] )
6 {
7 System.out.println( "Welcome to Java Programming!" );
8 }
9 }
A Simple GUI Program: Printing a
Line of Text
โ€ข Display
โ€“ Most Java applications use windows or a dialog box
โ€ข We have used command window
โ€“ Class JOptionPane allows us to use dialog boxes
โ€ข Packages
โ€“ Set of predefined classes for us to use
โ€“ Groups of related classes called packages
โ€ข Group of all packages known as Java class library or Java
applications programming interface (Java API)
โ€“ JOptionPane is in the javax.swing package
โ€ข Package has classes for using Graphical User Interfaces
(GUIs)
1 // Fig. 2.6: Welcome4.java
2 // Printing multiple lines in a dialog box
3 import javax.swing.JOptionPane; // import class JOptionPane
4
5 public class Welcome4 {
6 public static void main( String args[] )
7 {
8 JOptionPane.showMessageDialog(
9 null, "WelcomentonJavanProgramming!" );
10
11 System.exit( 0 ); // terminate the program
12 }
13 }
Packages
โ€ข Like โ€œnamespaceโ€ in C++
โ€ข How to use:
โ€“ C++: using namespace xxx
โ€“ Java: import xxx, or
import xxx.xx
A Simple Java Applet: Drawing a
String
โ€“ appletviewer only understands
<applet> tags
โ€ข Ignores everything else
โ€ข Minimal browser
โ€“ Executing the applet
โ€ขappletviewer WelcomeApplet.html
โ€ข Perform in directory containing .class file
1 <html>
2 <applet code="WelcomeApplet.class" width=300 height=30>
3 </applet>
4 </html>
1 // Fig. 3.6: WelcomeApplet.java
2 // A first applet in Java
33 import javax.swing.JApplet; // import class JApplet
4 import java.awt.Graphics; // import class Graphics
5
66 public class WelcomeApplet extends JApplet {
77 public void paint( Graphics g )
8 {
9 g.drawString( "Welcome to Java Programming!", 25, 25 );
10 }
11 }
1 <html>
2 <applet code="WelcomeApplet.class" width=300 height=30>
3 </applet>
4 </html>
import allows us to use
predefined classes (allowing
us to use applets and
graphics, in this case).
extends allows us to inherit the
capabilities of class JApplet.
Method paint is guaranteed to
be called in all applets. Its first
line must be defined as above.
1 // Fig. 3.8: WelcomeApplet2.java
2 // Displaying multiple strings
3 import javax.swing.JApplet; // import class JApplet
4 import java.awt.Graphics; // import class Graphics
5
6 public class WelcomeApplet2 extends JApplet {
7 public void paint( Graphics g )
8 {
99 g.drawString( "Welcome to", 25, 25 );
10 g.drawString( "Java Programming!", 25, 40 );
11 }
12 }
1 <html>
2 <applet code="WelcomeApplet2.class" width=300 height=45>
3 </applet>
4 </html>
The two drawString statements
simulate a newline. In fact, the
concept of lines of text does not
exist when drawing strings.
1 // Displaying text and lines
2 import javax.swing.JApplet; // import class JApplet
3 import java.awt.Graphics; // import class Graphics
4
5 public class WelcomeLines extends JApplet {
6 public void paint( Graphics g )
7 {
8 g.drawLine( 15, 10, 210, 10 );
99 g.drawLine( 15, 30, 210, 30 );
10 g.drawString( "Welcome to Java Programming!", 25, 25 );
11 }
12 }
1 <html>
2 <applet code="WelcomeLines.class" width=300 height=40>
3 </applet>
4 </html>
Draw horizontal lines with
drawLine (endpoints have same
y coordinate).

More Related Content

What's hot

History of java'
History of java'History of java'
History of java'deepthisujithra
ย 
JAVA Program Examples
JAVA Program ExamplesJAVA Program Examples
JAVA Program ExamplesProf Chethan Raj C
ย 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Mr. Akaash
ย 
Basic java part_ii
Basic java part_iiBasic java part_ii
Basic java part_iiKhaled AlGhazaly
ย 
Advance java prasentation
Advance java prasentationAdvance java prasentation
Advance java prasentationdhananajay95
ย 
Java Presentation
Java PresentationJava Presentation
Java Presentationpm2214
ย 
Java basics notes
Java basics notesJava basics notes
Java basics notespoonguzhali1826
ย 
Chapter 1 introduction to java technology
Chapter 1 introduction to java technologyChapter 1 introduction to java technology
Chapter 1 introduction to java technologysshhzap
ย 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machineLaxman Puri
ย 
Chapter 1
Chapter 1Chapter 1
Chapter 1siragezeynu
ย 
Learn Java Part 1
Learn Java Part 1Learn Java Part 1
Learn Java Part 1Gurpreet singh
ย 
Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz SAurabh PRajapati
ย 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1sotlsoc
ย 
Lec 3 01_aug13
Lec 3 01_aug13Lec 3 01_aug13
Lec 3 01_aug13Palak Sanghani
ย 
Java Tutorial to Learn Java Programming
Java Tutorial to Learn Java ProgrammingJava Tutorial to Learn Java Programming
Java Tutorial to Learn Java Programmingbusiness Corporate
ย 

What's hot (18)

History of java'
History of java'History of java'
History of java'
ย 
JAVA Program Examples
JAVA Program ExamplesJAVA Program Examples
JAVA Program Examples
ย 
Introduction to java programming part 1
Introduction to java programming   part 1Introduction to java programming   part 1
Introduction to java programming part 1
ย 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
ย 
Basic java part_ii
Basic java part_iiBasic java part_ii
Basic java part_ii
ย 
Advance java prasentation
Advance java prasentationAdvance java prasentation
Advance java prasentation
ย 
Java introduction
Java introductionJava introduction
Java introduction
ย 
Java Presentation
Java PresentationJava Presentation
Java Presentation
ย 
Java basics notes
Java basics notesJava basics notes
Java basics notes
ย 
Chapter 1 introduction to java technology
Chapter 1 introduction to java technologyChapter 1 introduction to java technology
Chapter 1 introduction to java technology
ย 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
ย 
Chapter 1
Chapter 1Chapter 1
Chapter 1
ย 
Learn Java Part 1
Learn Java Part 1Learn Java Part 1
Learn Java Part 1
ย 
Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz
ย 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
ย 
Lec 3 01_aug13
Lec 3 01_aug13Lec 3 01_aug13
Lec 3 01_aug13
ย 
Introduction to java technology
Introduction to java technologyIntroduction to java technology
Introduction to java technology
ย 
Java Tutorial to Learn Java Programming
Java Tutorial to Learn Java ProgrammingJava Tutorial to Learn Java Programming
Java Tutorial to Learn Java Programming
ย 

Similar to Java ppts unit1

Java basics notes
Java basics notesJava basics notes
Java basics notessanchi Sharma
ย 
Java basics notes
Java basics notesJava basics notes
Java basics notesNexus
ย 
Java basics notes
Java basics notesJava basics notes
Java basics notesGomathi Gomu
ย 
Javalecture 1
Javalecture 1Javalecture 1
Javalecture 1mrinalbhutani
ย 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT studentsPartnered Health
ย 
basic_java.ppt
basic_java.pptbasic_java.ppt
basic_java.pptsujatha629799
ย 
Java1 in mumbai
Java1 in mumbaiJava1 in mumbai
Java1 in mumbaivibrantuser
ย 
Applets 101-fa06
Applets 101-fa06Applets 101-fa06
Applets 101-fa06nrayan
ย 
Java lab1 manual
Java lab1 manualJava lab1 manual
Java lab1 manualnahalomar
ย 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introductionjyoti_lakhani
ย 
Java Programming concept
Java Programming concept Java Programming concept
Java Programming concept Prakash Poudel
ย 
java basic for begginers
java basic for begginersjava basic for begginers
java basic for begginersdivaskrgupta007
ย 
212 kuliah 01 pengenalan pemrograman berorientasi objek (java)
212 kuliah 01   pengenalan pemrograman berorientasi objek (java)212 kuliah 01   pengenalan pemrograman berorientasi objek (java)
212 kuliah 01 pengenalan pemrograman berorientasi objek (java)yuan99
ย 
j-chap1-Basics.ppt
j-chap1-Basics.pptj-chap1-Basics.ppt
j-chap1-Basics.pptSmitaBorkar9
ย 

Similar to Java ppts unit1 (20)

Java basics notes
Java basics notesJava basics notes
Java basics notes
ย 
Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)
ย 
Java basics notes
Java basics notesJava basics notes
Java basics notes
ย 
Java basics notes
Java basics notesJava basics notes
Java basics notes
ย 
Javalecture 1
Javalecture 1Javalecture 1
Javalecture 1
ย 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
ย 
basic_java.ppt
basic_java.pptbasic_java.ppt
basic_java.ppt
ย 
Java1 in mumbai
Java1 in mumbaiJava1 in mumbai
Java1 in mumbai
ย 
Applets 101-fa06
Applets 101-fa06Applets 101-fa06
Applets 101-fa06
ย 
Java1
Java1Java1
Java1
ย 
Java1
Java1Java1
Java1
ย 
Java lab1 manual
Java lab1 manualJava lab1 manual
Java lab1 manual
ย 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
ย 
Java platform
Java platformJava platform
Java platform
ย 
Java Programming concept
Java Programming concept Java Programming concept
Java Programming concept
ย 
Letest
LetestLetest
Letest
ย 
java basic for begginers
java basic for begginersjava basic for begginers
java basic for begginers
ย 
212 kuliah 01 pengenalan pemrograman berorientasi objek (java)
212 kuliah 01   pengenalan pemrograman berorientasi objek (java)212 kuliah 01   pengenalan pemrograman berorientasi objek (java)
212 kuliah 01 pengenalan pemrograman berorientasi objek (java)
ย 
j-chap1-Basics.ppt
j-chap1-Basics.pptj-chap1-Basics.ppt
j-chap1-Basics.ppt
ย 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
ย 

Recently uploaded

VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...SUHANI PANDEY
ย 
Call Now โ˜Ž 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now โ˜Ž 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.soniya singh
ย 
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft DatingDubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft Datingkojalkojal131
ย 
Hireโ† Young Call Girls in Tilak nagar (Delhi) โ˜Ž๏ธ 9205541914 โ˜Ž๏ธ Independent Esc...
Hireโ† Young Call Girls in Tilak nagar (Delhi) โ˜Ž๏ธ 9205541914 โ˜Ž๏ธ Independent Esc...Hireโ† Young Call Girls in Tilak nagar (Delhi) โ˜Ž๏ธ 9205541914 โ˜Ž๏ธ Independent Esc...
Hireโ† Young Call Girls in Tilak nagar (Delhi) โ˜Ž๏ธ 9205541914 โ˜Ž๏ธ Independent Esc...Delhi Call girls
ย 
Call Now โ˜Ž 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.Call Now โ˜Ž 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.soniya singh
ย 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...SUHANI PANDEY
ย 
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...SUHANI PANDEY
ย 
Busty DesiโšกCall Girls in Vasundhara Ghaziabad >เผ’8448380779 Escort Service
Busty DesiโšกCall Girls in Vasundhara Ghaziabad >เผ’8448380779 Escort ServiceBusty DesiโšกCall Girls in Vasundhara Ghaziabad >เผ’8448380779 Escort Service
Busty DesiโšกCall Girls in Vasundhara Ghaziabad >เผ’8448380779 Escort ServiceDelhi Call girls
ย 
VVVIP Call Girls In Connaught Place โžก๏ธ Delhi โžก๏ธ 9999965857 ๐Ÿš€ No Advance 24HRS...
VVVIP Call Girls In Connaught Place โžก๏ธ Delhi โžก๏ธ 9999965857 ๐Ÿš€ No Advance 24HRS...VVVIP Call Girls In Connaught Place โžก๏ธ Delhi โžก๏ธ 9999965857 ๐Ÿš€ No Advance 24HRS...
VVVIP Call Girls In Connaught Place โžก๏ธ Delhi โžก๏ธ 9999965857 ๐Ÿš€ No Advance 24HRS...Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
ย 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...SUHANI PANDEY
ย 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...singhpriety023
ย 
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceReal Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceEscorts Call Girls
ย 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubaikojalkojal131
ย 
Call Now โ˜Ž 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now โ˜Ž 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.soniya singh
ย 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...roncy bisnoi
ย 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersDamian Radcliffe
ย 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...Escorts Call Girls
ย 

Recently uploaded (20)

Low Sexy Call Girls In Mohali 9053900678 ๐ŸฅตHave Save And Good Place ๐Ÿฅต
Low Sexy Call Girls In Mohali 9053900678 ๐ŸฅตHave Save And Good Place ๐ŸฅตLow Sexy Call Girls In Mohali 9053900678 ๐ŸฅตHave Save And Good Place ๐Ÿฅต
Low Sexy Call Girls In Mohali 9053900678 ๐ŸฅตHave Save And Good Place ๐Ÿฅต
ย 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
ย 
Call Now โ˜Ž 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now โ˜Ž 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
ย 
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft DatingDubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
ย 
Hireโ† Young Call Girls in Tilak nagar (Delhi) โ˜Ž๏ธ 9205541914 โ˜Ž๏ธ Independent Esc...
Hireโ† Young Call Girls in Tilak nagar (Delhi) โ˜Ž๏ธ 9205541914 โ˜Ž๏ธ Independent Esc...Hireโ† Young Call Girls in Tilak nagar (Delhi) โ˜Ž๏ธ 9205541914 โ˜Ž๏ธ Independent Esc...
Hireโ† Young Call Girls in Tilak nagar (Delhi) โ˜Ž๏ธ 9205541914 โ˜Ž๏ธ Independent Esc...
ย 
Call Now โ˜Ž 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.Call Now โ˜Ž 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
ย 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
ย 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
ย 
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
ย 
Busty DesiโšกCall Girls in Vasundhara Ghaziabad >เผ’8448380779 Escort Service
Busty DesiโšกCall Girls in Vasundhara Ghaziabad >เผ’8448380779 Escort ServiceBusty DesiโšกCall Girls in Vasundhara Ghaziabad >เผ’8448380779 Escort Service
Busty DesiโšกCall Girls in Vasundhara Ghaziabad >เผ’8448380779 Escort Service
ย 
VVVIP Call Girls In Connaught Place โžก๏ธ Delhi โžก๏ธ 9999965857 ๐Ÿš€ No Advance 24HRS...
VVVIP Call Girls In Connaught Place โžก๏ธ Delhi โžก๏ธ 9999965857 ๐Ÿš€ No Advance 24HRS...VVVIP Call Girls In Connaught Place โžก๏ธ Delhi โžก๏ธ 9999965857 ๐Ÿš€ No Advance 24HRS...
VVVIP Call Girls In Connaught Place โžก๏ธ Delhi โžก๏ธ 9999965857 ๐Ÿš€ No Advance 24HRS...
ย 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
ย 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
ย 
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceReal Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
ย 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
ย 
Call Now โ˜Ž 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now โ˜Ž 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
ย 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
ย 
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
Russian Call Girls in %(+971524965298  )#  Call Girls in DubaiRussian Call Girls in %(+971524965298  )#  Call Girls in Dubai
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
ย 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
ย 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
ย 

Java ppts unit1

  • 1. A little cup of Java-coffee Priyanka Gupta CSE Dept. Mcsgoc
  • 2. Todayโ€™s session โ€ข Part-1) Java overview โ€“ What java is โ€“ Java features โ€“ Javaโ€™s cross-platform โ€ข Part-2) two simple and typical java programs โ€“ A stand-lone java and its running โ€“ A applet and its running
  • 4. What Java is โ€ข Java is an โ€œeasyโ€ programming language, โ€“ just a tool like C++, VB, โ€ฆand English. Somehow a language tool itself is not so complex. โ€ข Java works for internet project(mainly), and apply โ€œ3-tired architectureโ€, coding on the server-side โ€“ So besides Java language knowledge, we need to learn lots of thing about telecommunication on WEB, to finish a real-time project.
  • 5. What Java is(continue) โ€ข Java applies Object-Oriented Tech. โ€“ Java is not so difficulty, though OOP is. A java expert must be an OOP expert. โ€ข Java is slower than C++ ( 3-5 times), Javaโ€™s database function is slower than VB. โ€ข Java is very portable: cross-platform
  • 6. Javaโ€™s Features โ€ข Simple Java omits many rarely used, poorly understood, confusing features of C++. Say : No Pointer! No dynamic delete. โ€ข Object Oriented Object โ€“oriented design is a technology that focuses design on the data (object) and on the interfaces to it. Letโ€™s say, everything is an object, everything will become a class in Java. Every java program, in top- level view, is classes.
  • 7. Javaโ€™s Features(continue) โ€ข Robust The single biggest difference between Java and C/C++ is that Java has โ€œa inner safe pointer-modelโ€, therefore it eliminates the possibility of overwriting memory and corrupting data, so programmers feel very safe in coding.
  • 8. Javaโ€™s Features(continue) โ€ข GUI [Java-Swing] For some reason, Sun believe their java-swing is very important, so they always put it in their certificate-tests. โ€ข Multi-threaded โ€ข Secure [ Exception handling ] โ€ข Dynamic [ for Server-side coding]
  • 9. Javaโ€™s cross-platform โ€ข Interpreted Execute: cross-platform why: For cross-platform purpose. Once coding, run anywhere. The Java interpreter ( java.exe and its javaVirtualMachine) can execute compiled Java-byte-codes(Xxx.class) directly on any machine to which the interpreter has been ported. How: ( eg. Dos command line style) - Edit source code โ€œdemo.javaโ€ , by notepad/or other IDE tools - Compile ( javac.exe ) โ€œdemo.javaโ€๏ƒ  javac Demo.java ๏ƒ  Java byte codes, namely, Demo.class - Execute (Interpreted Execute) java Demo โ€ข Speed issue AND new solutions: java is slower than c++ in running. however, by now, there are some new technology of Java compiler, such as โ€œJust-in-timeโ€, and โ€œHotSpot adaptive Compilerโ€. They make java very faster than before.
  • 10. Java: Run in Virtual Cpu :cross-platfrom Demo.java๏ƒ  Compile ๏ƒ Demo.class๏ƒ  link๏ƒ  xxx.class Source-code โ€œjavacโ€ byte-code files bytecode program ๏ƒ interpretedly run on VM |--๏ƒ  Intel CPU (virtual CPU: JSDK ) |--๏ƒ  โ€ฆ CPU |--๏ƒ  Apple CPU
  • 11. Part-2 2 samples โ€ข How many kinds of java programs ? โ€ข Demo-1: Stand-lone sample โ€ข Demo-2: an Applet sample
  • 12. How many kinds of Java Programs? โ€ข Un-network app.: (1)Standalone Java program (today) โ€ข Network app: non-standalone Java program Internet: (2)Applet , (today) (3)servlet (4)JavaBean classes Intranet: (5)EJB ( EnterpriseJavaBean ), (6)RMI, etc
  • 13. Standalone Java Program โ€ข The main() method public static void main(String args[]){ ... } public--- the interpreter can call it static ----It is a static method belonging to the class void -----It does not return a value String----It always has an array of String objects as its formal parameter. the array contains any arguments passed to the program on the command line the source fileโ€™s name must match the class name which main method is in
  • 14. Java program 1 // Fig. 2.1: Welcome1.java 2 // A first program in Java 3 4 public class Welcome1 { 5 public static void main( String args[] ) 6 { 7 System.out.println( "Welcome to Java Programming!" ); 8 } Welcome to Java Programming! 9 }
  • 15. Java program 1 // Fig. 2.1: Welcome1.java 2 // A first program in Java 3 4 public class Welcome1 { 5 public static void main( String args[] ) 6 { 7 System.out.println( "Welcome to Java Programming!" ); 8 } 9 }
  • 16. A Simple GUI Program: Printing a Line of Text โ€ข Display โ€“ Most Java applications use windows or a dialog box โ€ข We have used command window โ€“ Class JOptionPane allows us to use dialog boxes โ€ข Packages โ€“ Set of predefined classes for us to use โ€“ Groups of related classes called packages โ€ข Group of all packages known as Java class library or Java applications programming interface (Java API) โ€“ JOptionPane is in the javax.swing package โ€ข Package has classes for using Graphical User Interfaces (GUIs)
  • 17. 1 // Fig. 2.6: Welcome4.java 2 // Printing multiple lines in a dialog box 3 import javax.swing.JOptionPane; // import class JOptionPane 4 5 public class Welcome4 { 6 public static void main( String args[] ) 7 { 8 JOptionPane.showMessageDialog( 9 null, "WelcomentonJavanProgramming!" ); 10 11 System.exit( 0 ); // terminate the program 12 } 13 }
  • 18. Packages โ€ข Like โ€œnamespaceโ€ in C++ โ€ข How to use: โ€“ C++: using namespace xxx โ€“ Java: import xxx, or import xxx.xx
  • 19. A Simple Java Applet: Drawing a String โ€“ appletviewer only understands <applet> tags โ€ข Ignores everything else โ€ข Minimal browser โ€“ Executing the applet โ€ขappletviewer WelcomeApplet.html โ€ข Perform in directory containing .class file 1 <html> 2 <applet code="WelcomeApplet.class" width=300 height=30> 3 </applet> 4 </html>
  • 20. 1 // Fig. 3.6: WelcomeApplet.java 2 // A first applet in Java 33 import javax.swing.JApplet; // import class JApplet 4 import java.awt.Graphics; // import class Graphics 5 66 public class WelcomeApplet extends JApplet { 77 public void paint( Graphics g ) 8 { 9 g.drawString( "Welcome to Java Programming!", 25, 25 ); 10 } 11 } 1 <html> 2 <applet code="WelcomeApplet.class" width=300 height=30> 3 </applet> 4 </html> import allows us to use predefined classes (allowing us to use applets and graphics, in this case). extends allows us to inherit the capabilities of class JApplet. Method paint is guaranteed to be called in all applets. Its first line must be defined as above.
  • 21. 1 // Fig. 3.8: WelcomeApplet2.java 2 // Displaying multiple strings 3 import javax.swing.JApplet; // import class JApplet 4 import java.awt.Graphics; // import class Graphics 5 6 public class WelcomeApplet2 extends JApplet { 7 public void paint( Graphics g ) 8 { 99 g.drawString( "Welcome to", 25, 25 ); 10 g.drawString( "Java Programming!", 25, 40 ); 11 } 12 } 1 <html> 2 <applet code="WelcomeApplet2.class" width=300 height=45> 3 </applet> 4 </html> The two drawString statements simulate a newline. In fact, the concept of lines of text does not exist when drawing strings.
  • 22. 1 // Displaying text and lines 2 import javax.swing.JApplet; // import class JApplet 3 import java.awt.Graphics; // import class Graphics 4 5 public class WelcomeLines extends JApplet { 6 public void paint( Graphics g ) 7 { 8 g.drawLine( 15, 10, 210, 10 ); 99 g.drawLine( 15, 30, 210, 30 ); 10 g.drawString( "Welcome to Java Programming!", 25, 25 ); 11 } 12 } 1 <html> 2 <applet code="WelcomeLines.class" width=300 height=40> 3 </applet> 4 </html> Draw horizontal lines with drawLine (endpoints have same y coordinate).