Downloaded with the Web page and launched by the Internet browser
Servlets
Run by Web server on the server
Typically generate Web content
Applications
Programs that run standalone on a client
Write the source code
- Using an Integrated Development Environment (IDE) or text editor. Save in a .java file
- Creates .class file
- Run by the Java Virtual Machine
Sample Program
// FirstProgram.java
public class FirstProgram {
public static void main( String [] args )
{
System.out.println (“Java Program”);
}
}
C:\ javac FirstProgram.java
C:\java FirstProgram
Java Program
The first line of the program uses the keyword class to declare that a new class is being defined.
A class is Java’s basic unit of encapsulation.
FirstProgram is the name of the class.
The class definition begins with an opening curly brace { and ends with a closing curly brace }
All program activity occurs within a class.
The next line of the program begins the main() method.
This is the line at which the program will begin executing.
All Java applications begin execution by calling main(). Just like C and C++
Statements and expressions are similar to those in other languages, and in most cases, identical to those of C or C++.
Leave a Reply