Prog 731 Java Topic 1 (Introduction of Java Language and Oop)
Prog 731 Java Topic 1 (Introduction of Java Language and Oop)
HYBRID LEARNING
Sun describes it as
"A simple, object-oriented, distributed, interpreted, robust, secure,
architecture neutral, portable, high-performance, multi-threaded and
dynamic language."
Object-Oriented
Designed to support Object-Oriented concepts
However, does contain non-Object-Oriented primitive data types
Distributed
Applications are constructed using objects. Objects can be
distributed in multiple locations within a network environment.
Extensive integration with TCP/IP
Interpreted
Java compiles to byte-code (not machine code). Byte code is
interpreted.
Most Java versions after 1.2 include a JIT (Just-In-Time) compiler
which compiles byte code to machine code.
Robust
Memory management is done automatically
Use of pointers is limited
Secure
All Java code subject to security model.
Architecture-Neutral/Portable
Compiled Java (byte code) will run on any platform which has a
Java Virtual Machine
The Java Virtual Machine is available for almost all platforms...
Even mainframes.
High-Performance
Originally, Java's performance was poor.
Now, Java's performance rivals C++.
Multi-Threaded
Processes contain multiple threads of execution.
Similar to multi-tasking but all threads share the same memory
space.
Dynamic
Makes heavy use of dynamic memory allocation.
Classes can be dynamically loaded at any time.
Because Java source code is compiled to byte code and the byte
code is interpreted, Java code can be executed anywhere an
interpreter is available.
• Object-oriented
• Improved on C++
• Security
• APIs (Application Programming Interface)
‒ Lots of prewritten code
• Distributed
‒ Able to run over the network
• “Write once, run anywhere”
‒ Platform independent
• Application
‒ Runs natively on the system through the Java Virtual Machine (JVM)
• Applet
‒ Runs in a browser
‒ Does smaller tasks
• Programs
‒ Both applets and applications are “Java programs”
i386 VM
Java Java
Source.java SPARC VM
Compiler Bytecode
Source.class
PPC VM
Java SDK
JRE
JVM
There are many IDEs available. Some are public domain and
some are commercial:
Symantic Visual Cafe
JBuilder
IBM Visual Age
Kawa
Forte for Java
Most IDEs offer a "demo" mode so you can try before you buy.
To execute, run the Java VM and include the name of the class
which contains the "main" method as the first command line
parameter.
/*
* Sam ram
* ITP 109 Fall 2011, 8/30/2011
* HelloWorld program
*/
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
• Bugs:
‒ Program does not compile
‒ Program produces output that is not expected when it executes
• Debugging is the act of removing them
• A programmer spends about half of his/her time debugging code
• Compiler error
• Executing (or run-time) error
What is the Java Virtual Machine and what are its responsibilities?