Introduction to Computing
Using Java
Introduction to Java
2019 1a Michael Fung, CS&E, The Chinese University of HK 1
Hard and Soft
Physical devices comprising a computer system
are referred to as hardware.
Computer programs that run on a computer are
referred to as software.
2019 1a Michael Fung, CS&E, The Chinese University of HK 2
Software: Program and Data
A computer program is merely a collection of
instructions to process data.
This course is focused on how to design and
produce quality software, i.e. writing complete
and precise computer programs to control
computers.
2019 1a Michael Fung, CS&E, The Chinese University of HK 3
What is Data in Computer?
Instant messages, web page
MP4 Movie, JPG Image, MP3 Song
Teaching time table, Grade Point Average (GPA)
Phone number and credit card number
Joy-pad button status, weapon list in a game
Text document
Program
Basically anything in computer manageable
form!
2019 1a Michael Fung, CS&E, The Chinese University of HK 4
Compiler / Interpreter
Still remember the Pros & Cons of writing
High-level & Low-level language?
Translators do the translation task for us
Program Written in
High-level Language
Compiler/Interpreter
e.g. Pascal, C
Executable Program in
Low-level Language
e.g. Intel x86 machine code
2019 1a Michael Fung, CS&E, The Chinese University of HK 5
Really Cross Platform?!
Windows on
HP UX
Tr e Intel x86
a t
ns ls a
la an
te
Tr
Basic Program [hello.bas]
Translate
te
Tr
sl a
an
an
sl a
Tr
te
Mac Sun
…
2019 1a Michael Fung, CS&E, The Chinese University of HK 6
Pitfalls
Store and use different compiled versions
Availability of compiler(s) is assumed
Compiler compatibility problem
Re-compile all versions after an update
How about a new machine/ computer architecture?
2019 1a Michael Fung, CS&E, The Chinese University of HK 7
Java?
Web-based applications
Enterprise usage
Home usage
Set-top box, e.g. cable TV
Mobile usage
Android Apps
2019 1a Michael Fung, CS&E, The Chinese University of HK 8
Java Compilation Model
Java Program [Hello.java]
Compile
Java Compiler
Java Byte Code [Hello.class]
We do this once
2019 1a Michael Fung, CS&E, The Chinese University of HK 9
Java Compilation Model
Someone do this for us
native code
Intel x86
Java Byte Code [Hello.class] Translate Smartphone
Java Virtual
Mac
Machine (JVM)
ARM
2019 1a Michael Fung, CS&E, The Chinese University of HK 10
Java Compilation Model
Java Program [Hello.java] The whole grand picture
Compile native code
Java Compiler
Intel x86
Java Byte Code [Hello.class] Translate Smartphone
Java Virtual
Mac
Machine (JVM)
ARM
2019 1a Michael Fung, CS&E, The Chinese University of HK 11
What is a VM?
Virtual Machine is a piece of software
VM is a software-based simulator
It simulates another machine, e.g.
– Game console emulators
Related technology: virtualization/ hardware emulation
– Microsoft Virtual PC
– VMware
– Mac Parallels Desktop
2019 1a Michael Fung, CS&E, The Chinese University of HK 12
Scenario Explained
Now, each native speaker has an in-house translator
(called JVM) who understands Java Byte Code and
speaks the corresponding native language
– JVM emulates a Java Machine on different hardware.
We only need to prepare our program instructions in Java
Byte Code, for execution on a Java Machine/ JVM.
However, Java Byte Code is still hard for human, so we
learn the Java Language
2019 1a Michael Fung, CS&E, The Chinese University of HK 13
Portability: 海納百川、有容乃大
Java is a High Level Programming Language,
supporting
– standalone text and graphical applications
– client-side web development (applet)
– server-side web development (servlet, JSP)
– mobile applications (J2ME, MIDP, games, etc.)
– mobile platforms (Android Apps)
– embedded applications (Java card, set-top box)
2019 1a Michael Fung, CS&E, The Chinese University of HK 14
Summary
Java is compiled to byte code and can be run on
any platform that supports a Java Virtual
Machine. [portable]
Java Platform is available in Standard Edition
(SE), Enterprise Edition (EE), or Micro Edition
(ME).
NetBeans is a graphical IDE bundled with Java
for developing projects in Java.
2019 1a Michael Fung, CS&E, The Chinese University of HK 15