??sa???? st? JAV? ( - PowerPoint PPT Presentation

About This Presentation
Title:

??sa???? st? JAV? (

Description:

Title: Java Tutorial Part 1 Author: Vassilis Papataxiarhis Last modified by: vpap Created Date: 1/1/1601 12:00:00 AM Document presentation format – PowerPoint PPT presentation

Number of Views:74
Avg rating:3.0/5.0
Slides: 29
Provided by: VassilisPa1
Category:
Tags: jav | applets | java

less

Transcript and Presenter's Notes

Title: ??sa???? st? JAV? (


1
??sa???? st? JAV?(µ???? ?)
  • ?as???? ?apata???????
  • vpap_at_di.uoa.gr
  • ????µa ??t??e?µe??st?af?? ?????aµµat?sµ??
  • ??d?s???sa ??aµp? ?a????
  • ?µ?µa ?????f?????? ?a? ???ep??????????
  • ?????? ?a? ?ap?d?st??a?? ?a?ep?st?µ?? ??????

2
?as??? S?µe?a
  • ??sa??????? ?????f???e? ??a t? ???ssa Java
  • ?e???????a Java
  • ??µ? e??? Java p?????µµat??
  • ?a?a?t???st??? t?? ???ssa? Java
  • ?p?p???? ???at?t?te?
  • ??af???? µe C

3
?st????? St???e?a
  • ? Java d?µ?????????e t? 1991 ap? t?? James
    Gosling ?.?. st? Sun Microsystems.
  • ??????, ???µ?st??e Oak.
  • ??????? st???? ?ta? ? a??pt??? µ?a? ???ssa? p??
    ?a ?ta? a?e???t?t? p?atf??µa?, d??. e????a ?a
    ?pa??e pa?t??.
  • ???? t?? a??pt???? t?? ??ad??t???, ? Java ß???e
    p??sf??? ?daf?? ??a a??pt??? efa?µ????.

4
?? e??a? ? Java
  • ?e t? Java µp??e?? ?a ???e?? ?t? ?a? µe µ?a
    t?p??? d?ad??ast??? ???ssa.
  • ?as??eta? st? a?t??e?µe??st?af?? µ??t??? a????s??
    ?a? s?ed?asµ??.
  • ??e? p????? ?µ???t?te? st? s??ta?t??? t?? µe t?
    C.

5
????te?t????? Java
  • ?d?a?te??t?ta
  • Compile once, run everywhere

6
?etafe?s?µ?t?ta
  • ?a a??e?a p??a??? ??d??a Java (.java)
    µeta???tt????ta? se a??e?a bytecode (.class) ?a?
    ??? se ??d??a µ??a??? (machine code).
  • ?a bytecode a??e?a e??a? a?e???t?ta µ??a??? ?a?
    µp????? ?a e?te?est??? ap? µ?a Java Virtual
    Machine (JVM).
  • ?p?????? JVM s?ed?? ??a ???e p?atf??µa.
  • Windows, Linux, Solaris, ?.?.

7
??µ? ?????aµµ?t??
  • ?? ???se?? ???a?????ta? se .java a??e?a
  • Se ???e a??e?? p??pe? ?a ?p???e? t? p??? µ?a
    public ???s?
  • S?????? p?a?t??? 1 ???s? a?? a??e??
  • ?? ???µa t?? a??e??? ta?t??eta? µe t? ???µa t??
    public ???s?? p?? pe????e?

8
Java 2 Platform
  • ?p?te?e?ta? ap? 2 µ???
  • Java Virtual Machine
  • Java APIs
  • Java APIs
  • ??ß??????e? p?? pa?????? ßas???? s??a?t?se??
    ?t??µe? ??a ???s?
  • 3 e?d?se??
  • Java 2 Standard Edition (J2SE) desktop ?a?
    d??t?a??? efa?µ????
  • Java 2 Enterprise Edition (J2EE) eta??????
    efa?µ????
  • Java 2 Micro Edition (J2ME) ???s? se ????t??
    s?s?e???

9
Java Virtual Machine
  • ??te?e? µeta???tt?sµ??a Java p?????µµata p??
    ???µ????ta? bytecode a??e?a.
  • ?a bytecode a??e?a e??a? a?e???t?ta p?atf??µa?
    ?a? µp????? ?a e?te?est??? ap? ?p????d?p?te
    ?p?????st? d?a??te? µ?a JVM.
  • ? JVM f??t??e? t?? ???se?? p?? ??e?????ta? ??a ?a
    e?te?este? t? Java p????aµµa (class loader).
  • ? JVM ep??????e? (verifies) t?? e?????t?ta t??
    bytecode a??e??? p??? ta e?te??se? (bytecode
    verifier).

10
JDK - JRE
  • Java Development Kit (JDK)
  • ?e??ß????? a??pt???? efa?µ???? st? ???ssa Java
  • ?e????e? JVM ?a? Java ß?ß??????e?
  • ???a?e?a, ?p?? jar ?a? javadoc
  • Java Runtime Environment (JRE)
  • ?p?s????? t?? JDK
  • ??s?ast??? pe????e? µ?a ???p???s? t?? JVM µe
    s??p? t? d??at?t?ta e?t??es?? p????aµµ?t?? Java.

11
???e?a Java
  • ???e?a Java
  • .java p??a??? ??d??a? (source file)
  • .class bytecode a??e?? (pa???eta? ap? compiler)
  • .jar s????a s?et???? ???se??
  • ?eta???tt????µe ta .java a??e?a p?? pe???????
    ???se??.
  • ?? µeta???tt?sµ??? a??e?? .class p?? e?te???µe ?a
    p??pe? ?a pe????e? a???ß?? µ?a main s????t?s?
    (ap? e?e? ?e???? ? e?t??es?)

12
F?se?? ??t??es??
java compiler
bytecode file
interpreter (VM)
Source code
Hello.java
Hello.class
javac
java
F?s? ???a?e?? ???d??
WRITE Text editor ???e?? .java
COMPILE Java compiler ???e?? .class (bytecode)
RUN Java interpreter ???d?? p?????µµat??
13
Hello World ?
  • ??µa 1
  • ??µa 2
  • javac HelloWorld.java
  • ??µa 3
  • java HelloWorld

14
??p?? ?ed?µ???? st? Java (1/2)
  • ???t??e?e?? t?p?? ded?µ???? (primitive data
    types) e?d???? t?p?? ded?µ????, built-ins t??
    ???ssa?, µ??e??? a?e???t?t? p?atf??µa?
  • ?e? ???s?µ?p??e?ta? ? ???? new ??a t?
    d?µ??????a µ?a? µetaß??t?? p??t??e???? t?p??
  • ?.?. int i 1000

15
??p?? ?ed?µ???? st? Java (2/2)
  • ??t??e?µe?a
  • St? Java ta p??ta (e?t?? t?? primitives) e??a?
    a?t??e?µe?a t?? ???s?? java.lang.Object ?a?
    d?µ????????ta? µe t? ???? new
  • ?.?. Date d new Date()
  • String s new String(Vassilis)
  • ?a?ade??µata
  • String a???????a ?a?a?t???? (???s?
    java.lang.String), t?p??? de? ap?te?e? p??t??e??
    t?p? ded?µ????, a??? p?a?t??? µp????µe ?a t??
    s?eft?µaste ?? t?t???
  • Arrays, Collections, Vectors, Int, Double,
    MyClass ??p.

16
?as??? St???e?a t?? Java
  • ?etaß??t??
  • ?a??µ??a µe C
  • ?e?est??
  • ?a??µ??a µe C
  • s?????s? Strings
  • instanceof operator
  • ?.?.
  • System.out.println(Size of array
    array.size())

17
static - final
  • Static
  • variable a???e? st?? ???s?
  • method ???s?µ?p??e? µ??? pa?aµ?t????
  • Final
  • variable apa???e?s? a??a??? t?µ?? e?t??
    eµß??e?a?
  • method de µp??e? ?a ???e? override
  • class de µp??e? ?a ???e? extend

18
??µ?? ??????? st? Java
  • ?a??µ??a µe C
  • ??µ?? ?p??????
  • if-else
  • switch-case
  • ??µ?? ?pa???????
  • for
  • while
  • do while
  • break, continue, return, goto

19
????se?? import
  • ?????? e?t??? st?? compiler ?a ?atast?se? ??at?
    ??a pa??t? (package) st? a??e?? ??d??a.
  • ?.?.
  • import java.util.Vector //µ??? t?? ???s? Vector
  • import java.util. //?,t? pe????eta? st?
    java.util

20
??a?e???s? ???µ??
  • G??eta? a?t?µata µ?s? e??? ??µat?? t?? garbage
    collector.
  • ??a ??µµ?t? µ??µ?? ape?e??e???eta? runtime ?ta?
    p???? de? ?p???e? ???? a?af??? p??? a?t? µ?sa st?
    p????aµµa.
  • ? ???st?? de? as???e?ta? (?a? de? µp??e? ?µesa ?a
    t? ???e?) µe t?? ape?e?????s? µ??µ??

21
?e?µ????s? ???e?a .jar
  • Javadoc
  • ??t?µat? pa?a???? te?µ????s?? se µ??f? html
    se??da? µ?s? t?? a??e??? ??d??a Java
  • ? ??d??a? s???p???e? µe t? ?e?µe?? te?µ????s??
    ape??e?a? p??sp??as?.
  • ???e?a .jar
  • ??e??????e? t? d?a?e???s? t?? Java a??e???
  • ???p???s? a??e??? se pa??ta

22
Java ?a? ??ad??t??
  • Java Applets
  • Web-efa?µ???? ?a? ??? t?p??? java p?????µµata
  • ??p??et???ta? se ?st?se??de?
  • ??te????ta? ap? t? JVM e?t?? e??? Web browser
  • ?p?st????? sockets, servlets, ?.?.

23
???e? ??af???? ap? C (1/3)
  • ? Java de? ep?t??pe? p???ap?? ???????µ???t?ta
    (??a ?????? ap??t?ta?)
  • ???e ???s? µp??e? ?a ???????µe? t? p??? ap? µ?a
    ???? ???s? (extends)
  • Interfaces ??µ?? p?? pe??????? µ? ???p???µ??e?
    s??a?t?se??, ????? µetaß??t??-µ??? ?a? de? e??a?
    ???se??
  • ??a ???s? µp??e? ?a ???e? implement pe??ss?te?a
    ap? ??a interface

24
???e? ??af???? ap? C (2/3)
  • ? Java ?e??e?ta? e? ???e? ap???ste?? ???ssa ap?
    t? C.
  • ??e? ?? Java µ???d?? e??a? ?p?? ?? virtual t??
    C.
  • ? Java de? ?p?st????e? de??te? (pointers).

25
???e? ??af???? ap? C (3/3)
  • ? Java de? ?p?st????e? defines, typedefs ?
    preprocessor. ?p?te, de ??e???eta? ??te a??e?a
    ?efa??da? (header files).
  • St? Java de? ?p?st??????ta? ?a??????? µetaß??t??.
    ??a??a?t??? static
  • St? Java de? ep?t??p??ta? s??a?t?se?? e?t??
    ???se?? (stand-alone functions).

26
???te???µe?e? ?????
  • The Source for Java Developers,
    http//java.sun.com/
  • The Java Tutorials, http//java.sun.com/docs/books
    /tutorial/
  • Learning Java, Pat Niemeyer Jonathan Knudsen
  • Thinking in Java, Bruce Eckel, http//www.mindview
    .net/Books/TIJ/

27
??? ep?µe?? f???
  • ???? ?a? ??a???se??
  • ?etat??p? ??t??e?µ????
  • ??s?d?? / ???d??
  • ???a?e?a ???pt????
  • ?p?p??s?eta T?µata

28
  • ???t?se?? ?
Write a Comment
User Comments (0)
About PowerShow.com