Share with others

                   Java Programs
Small programs designed to add interactivity to Web sites
Downloaded with the Web page and launched by the Internet browser


Run by Web server on the server
Typically generate Web content


Programs that run standalone on a client
Developing a Java Program 

Write the source code

  • Using an Integrated Development Environment (IDE) or text editor. Save in a .java file
Compile the source code:          javac
  • Creates .class file
Execute the application:         java ClassName
  • Run by the Java Virtual Machine

Sample Program

C:\ javac
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++.


Share with others