Professional Documents
Culture Documents
Java I Lecture 1 UPD1
Java I Lecture 1 UPD1
Chapter 1
Introduction to Computers,
the Internet and the Web
Javas
Major Advantage
over C & C++
Java is C without
the Guns and
Knives.
Java I--Copyright 2000-2004 Tom
Java Architecture
By now, Java itself has matured into its 3rd
version, named Java 2. This course is based
on Java 2. The most current is Java 2 (1.5.1)
Java is Object-Oriented--that means
everything in the language behaves like an
object.
What exactly that means will be explained
in the coming weeks.
Java I--Copyright 2000-2004 Tom
Java Architecture
Java Architecture
Java Architecture
Java Architecture
Hello.java
Java
Virtual
Machine
Run-Time
Environment
Java Architecture
Java Architecture
Java
Virtual
What is the
Machi
?
ne
C Source Code
C object module
compiled into
machine language
Java Architecture
Java bytecode
In contrast to conventional programming
languages, a Java program is not compiled
into native machine language.
Instead, Java makes bytecode.
Bytecode is the result of a compile, but
the compile results in an intermediate form
that stops short of native machine-specific
code.
Java Architecture
Java Architecture
Java Architecture
Write Once,
Run Anywhere.
Java I--Copyright 2000-2004 Tom
Java Source
The
bytecode
is met
half-way
by the
JVM.
JVM-Win
JVM-Mac
JVM-Unix
JVM-IBM
Wintel
Mac
UNIX
MVS
Java Architecture
Remote Code
Local Code
JDK 1.2
Security Model
SANDBOX
Objects in Java
In Java, Object Orientation is so
pervasive that its nearly impossible to
write a strictly procedural program in
the language.
Objects in Java
Objects in Java
Objects in Java
Objects in Java
Objects in Java
Objects in Java
javac
C:\javac Hello.java
Applications
Applets
Java I--Copyright 2000-2004 Tom
A Java Application
// HelloWorld.java Our first Java Application
public class HelloWorld
{
public static void main( String args[])
{
System.out.println( Hello World! );
}
}
Now
ouris Application
is complete.
We have
added the
The
This
double
theslashes
class name.
denote
a C++-style
comment.
method
are
lower
case.
main
is a
Everything
Everymain.
single
on the
bitAll
line
of methods
code
afterinthe
Java
double
mustslashes
sit
in curly
is brackets.
special
runs the program.
ignored
Classmethod--it
by
names
the compiler.
are actually
capitalized.
Words
the name are
Inwithin
any application,
youalso
arecapitalized.
always guaranteed
This
Java main
program
must
that
method
will
run.be saved in a file with the exact
same name--matching the upper case--as you see in blue
above: HelloWorld.java
Java I--Copyright 2000-2004 Tom
A Java Application
C:\>javac HelloWorld.java
C:\>
A successful compile of your java
program will return to a bare cursor, as
you see here.
Java I--Copyright 2000-2004 Tom
A Java Application
C:\>javac HelloWorld.java
C:\>java HelloWorld
Hello World!
To run your compiled Application,
you enter lowercase java HelloWorld
on the command line.
Notice, the .class extension is
omitted.
Java I--Copyright 2000-2004 Tom
In Class Activity
Now load the JDK1.4.1,
the documentation,
change the class path and
write your first Java program.