What Is A Java Program?
What Is A Java Program?
What Is A Java Program?
2-2 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Topics
2-3 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Purpose of a Computer Program
2-4 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Translating High-Level Code to Machine Code
Solaris OS
C Compiler
Solaris OS
Binary
Linux
C Compiler
Linux
C Binary
Code
Microsoft Windows
C Compiler Microsoft Windows
Binary
2-5 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Linked to Platform-Specific Libraries
Project
Libraries
Solaris OS
C Compiler
Solaris OS Solaris OS
Binary Executable
Project
Libraries
Linux
C Compiler
Linux Linux
Binary Executable
Project
Libraries
Microsoft Windows
Microsoft Windows C Compiler Microsoft Windows
Binary Executable
2-6 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Platform-Dependent Programs
Solaris OS Workstation
Solaris OS
Executable
Microsoft Windows
Executable Microsoft Windows Workstation
2-7 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Topics
2-8 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Key Features of the Java Language
Some of the features that set Java apart from most other
languages are that:
• It is platform-independent
• It is object-oriented
2-9 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Java Is Platform-Independent
Project
Libraries
Java Compiler
Solaris OS
Java Workstation
Bytecode
JRE
(.class file)
Linux
Workstation
JRE
Java Virtual
Machine
(JVM)
Microsoft Windows
Workstation
• Interaction of objects
• No prescribed sequence
• Benefits:
– Modularity
– Information hiding
– Code reuse
– Maintainability
ime
Runt
pile
Com
r
is a ss
e is l a is
od jav de ac. c
. e) . l e
c o fi the
r ce a . c e c jav i
a
s cod a
s
s by e.
sou in . our by t
ul byte
l
c ed tim
he ned file e s led s
re e ( he u t n
T tai Th mp
i e il T e
x
c
a ru
n
co Th f e av
co j
• Syntax:
javac SayHello.java
• Example:
javac SayHello.java
• Output:
Hello World!
A Java program can output data in many ways. Here are some
examples:
• To a file or database
• To the console
• To a webpage or other user interface