Beruflich Dokumente
Kultur Dokumente
Contents
• Java Language Features
• Java Environment
• Java Program Structure
• Java & Unicode
2
What is Java?
• Programming language
– Object-oriented
4
Java Environment
5
Installing SDK
6
Compilation
javac MyProgram.java
javac –classpath . MyProgram.java
7
Execution
• java MyProgram
• java –classpath . MyProgram
8
Java Program Structure
9
Java & Unicode
• Unicode(16 bit code) character set
can represent characters of almost
all languages.
• Java supports Unicode both internally
and externally
10
Objects in Java
Hello.java
Hello.class
Objects in Java
is called a class.
Objects in Java
16
Java Class Library
• The Java class library is organized
into a number of packages:
– java.lang --- general
– java.awt --- GUI
– java.io --- I/O
– java.util --- utilities
– java.applet --- applet
– java.net --- networking
Compiling A Java
• You have Program
created a Java
program called Hello.java
• To compile it, you run the JDK
supplied utility called:
javac
C:\javac Hello.java
If this was successful, a file
called:
First Java Program
• The two largest varieties of
Java programs:
Applications
Applets
First Java Program
Now
The ourisApplication
This
double the
slashes is complete.
class name.
denote We havecomment.
a “C++”-style added the
Everymethod “main”.
Everything
single bit of Allline
oncode
the methods
in Java
after aresit
must
the lower
double case.
in curly
slashes is is a
main
brackets.
Class special
names method--it
ignored are
by the actually runs the program.
capitalized.
compiler.
Words within In
the name
any are also you
application, capitalized.
are always guaranteed that
This Java program
method main must be saved in a file with the exact
will run.
same name--matching the upper case--as you see in blue
above: HelloWorld.java
A Java Application
C:\>javac
HelloWorld.java
C:\>
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.
In Class Activity