Lecture 1: Overview of Java
What is java?
Developed by Sun Microsystems (James Gosling)
A general-purpose object-oriented language
Based on C/C++
Designed for easy Web/Internet applications
Widespread acceptance
Java Features
Simple/
Object oriented
Platform Independent
Portable
Secure
Multithreaded
Getting Started: (1)
(1) Create the source file:
open a text editor, type in the code which defines a class
(HelloWorldApp) and then save it in a file (HelloWorldApp.java)
file and class name are case sensitive and must be matched
exactly (except the .java part)
Example Code: HelloWorldApp.java
/**
* The HelloWorldApp class implements an application
* that displays "Hello World!" to the standard output
*/
public class HelloWorldApp {
public static void main(String[] args) {
// Display "Hello World!"
System.out.println("Hello World!");
}
}
Java is CASE SENSITIVE!
Getting Started: (2)
(2) Compile the program:
compile HelloWorldApp.java by using the following command:
javac HelloWorldApp.java
it generates a file named HelloWorldApp.class
‘javac’ is not recognized as an internal or
external command, operable program or hatch file.
javac: Command not found
if you see one of these errors, you have two choices:
1) specify the full path in which the javac program locates every time.
For example:
C:\j2sdk1.4.2_09\bin\javac HelloWorldApp.java
2) set the PATH environment variable
THE END